diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-03-04 16:51:39 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-03-04 16:51:39 +0100 |
| commit | 79e3429ea8fb590f82b11f2b19a26427f2d1da4f (patch) | |
| tree | 07db0315d91ffbe64d9a3ba0cb448d2a0082c164 | |
| parent | 4ed70beabc73dd9aa1d2e06ab5902ded0801c404 (diff) | |
build(docker): allow specific config for staging service
| -rw-r--r-- | Dockerfile | 10 | ||||
| -rw-r--r-- | docker-compose.yml | 18 |
2 files changed, 22 insertions, 6 deletions
@@ -3,6 +3,10 @@ FROM node:16-alpine AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app + +ARG APP_ENV=production +ENV APP_ENV ${APP_ENV} + COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile @@ -13,6 +17,10 @@ RUN yarn install --frozen-lockfile # Rebuild the source code only when needed FROM node:16-alpine AS builder WORKDIR /app + +ARG APP_ENV=production +ENV APP_ENV ${APP_ENV} + COPY --from=deps /app/node_modules ./node_modules COPY . . @@ -27,6 +35,8 @@ RUN yarn build FROM node:16-alpine AS runner WORKDIR /app +ARG APP_ENV=production +ENV APP_ENV ${APP_ENV} ENV NODE_ENV production # Uncomment the following line in case you want to disable telemetry during runtime. # ENV NEXT_TELEMETRY_DISABLED 1 diff --git a/docker-compose.yml b/docker-compose.yml index c8d675b..8d0ad57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,21 +5,27 @@ services: context: . dockerfile: Dockerfile args: - DOCKER_PORT: ${APP_DOCKER_PORT_PROD:-3000} + APP_ENV: production + DOCKER_PORT: ${APP_DOCKER_PORT:-3000} container_name: apcom env_file: - .env + environment: + APP_ENV: production ports: - - '${APP_DOCKER_PORT_PROD:-3000}:${APP_DOCKER_PORT_PROD:-3000}' + - '${APP_DOCKER_PORT:-3000}:${APP_DOCKER_PORT:-3000}' restart: always - apcom-dev: + apcom-staging: build: context: . dockerfile: Dockerfile args: - DOCKER_PORT: ${APP_DOCKER_PORT_DEV:-3200} - container_name: apcom-dev + APP_ENV: staging + DOCKER_PORT: ${APP_STAGING_DOCKER_PORT:-3200} + container_name: apcom-staging env_file: - .env + environment: + APP_ENV: staging ports: - - '${APP_DOCKER_PORT_DEV:-3200}:${APP_DOCKER_PORT_DEV:-3200}' + - '${APP_STAGING_DOCKER_PORT:-3200}:${APP_STAGING_DOCKER_PORT:-3200}' |
