Skip to content
Discussion options

You must be logged in to vote

For build time values you need to use build args instead of environment variables. Here are the updated files:

# docker-compose.yml
version: '3.7'
services:
  fe:
    build: ./
    ports:
      - '3000:80'
    # the build args are defined by this key
    args:
      NEXT_PUBLIC_API_URI: arbitrary_value
# Dockerfile
FROM node:12.18.0-alpine
WORKDIR /app/

# here we are reading the value from the build args and inserting into the environment variables
ARG NEXT_PUBLIC_API_URI
ENV NEXT_PUBLIC_API_URI=${NEXT_PUBLIC_API_URI}

COPY . .
RUN npm i
RUN npm run build
EXPOSE 3000
EXPOSE 80
CMD ["npm", "run", "serve"]

Also, one more thing. In that case is the only option using publicRuntimeConfig? Ho…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@alingavriliuc
Comment options

@alamenai
Comment options

@tranquanghuy0801
Comment options

@alamenai
Comment options

@tranquanghuy0801
Comment options

Answer selected by AssisrMatheus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
6 participants