Skip to content

Commit

Permalink
build: Change frontend build to production configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
felipefg committed Jan 23, 2024
1 parent 77bf195 commit 0e905c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
- uses: actions/checkout@v4

- name: Build image
run: docker build frontend/ --file frontend/Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
run: docker build frontend/ --file frontend/Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --build-arg "NEXT_PUBLIC_CARTESI_NODE_URL=$NEXT_PUBLIC_CARTESI_NODE_URL"
env:
NEXT_PUBLIC_CARTESI_NODE_URL: ${{ vars.NEXT_PUBLIC_CARTESI_NODE_URL }}

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
Expand Down
25 changes: 10 additions & 15 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .


ARG NEXT_PUBLIC_CARTESI_NODE_URL
ENV NEXT_TELEMETRY_DISABLED 1

# FIXME: uncomment this for production
# RUN npm run build
RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
Expand All @@ -41,27 +40,24 @@ LABEL org.opencontainers.image.source https://github.com/prototyp3-dev/world-arc

WORKDIR /app

# FIXME: uncomment this for production
# ENV NODE_ENV production

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# FIXME: uncomment this for production
# COPY --from=builder /app/public ./public
RUN chown -R nextjs:nodejs /app
COPY --from=builder --chown=nextjs:nodejs /app/ ./

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
# FIXME: uncomment this for production
# COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
# COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

Expand All @@ -73,6 +69,5 @@ ENV HOSTNAME "0.0.0.0"

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
# FIXME: uncomment this for production
# CMD ["node", "server.js"]
CMD ["npm", "run", "dev"]
CMD ["node", "server.js"]

4 changes: 3 additions & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {
output: 'standalone'
}

module.exports = nextConfig

0 comments on commit 0e905c4

Please sign in to comment.