Add dynamic environment variables to Dockerfile for the npm build script

This commit is contained in:
Andrew 2024-02-03 15:31:16 +03:00
parent 7d74b56e95
commit a53c12b90d
2 changed files with 11 additions and 3 deletions

View File

@ -30,6 +30,8 @@ services:
args:
- APP_DIRECTORY=${APP_DIRECTORY:-/opt/strapi}
- NODE_ENV=${NODE_ENV:-18}
- STRAPI_ADMIN_BACKEND_URL=${STRAPI_ADMIN_BACKEND_URL:-https://strapi.enderman.ch}
- ADMIN_PATH=${ADMIN_PATH:-dashboard}
image: endermanch/strapi
container_name: "cms-strapi"
hostname: "strapi"

View File

@ -2,6 +2,13 @@ FROM node:18-alpine as build
ARG APP_DIRECTORY
ARG NODE_ENV
ARG STRAPI_ADMIN_BACKEND_URL
ARG ADMIN_PATH
# Set dynamic environment variables for the npm build script
ENV NODE_ENV ${NODE_ENV}
ENV STRAPI_ADMIN_BACKEND_URL ${STRAPI_ADMIN_BACKEND_URL}
ENV ADMIN_PATH ${ADMIN_PATH}
# Set working directory
WORKDIR ${APP_DIRECTORY}
@ -32,10 +39,9 @@ FROM node:18-alpine as production
ARG APP_DIRECTORY
ARG NODE_ENV
ENV TIMEZONE "UTC"
# Set local timezone
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone
# Set dynamic environment variables
ENV NODE_ENV ${NODE_ENV}
# Upgrade & install image processing dependency
RUN apk upgrade --no-cache && \