Passes environment variables through the Dockerfile

This commit is contained in:
Aaron Louie 2020-04-14 16:22:34 -04:00
parent 41b399e8a3
commit 201e65fdbf
4 changed files with 50 additions and 5 deletions

View File

@ -9,11 +9,15 @@ ADD package.json /crc-bpmn/
COPY . /crc-bpmn/
RUN npm install && \
npm run build:staging
npm run build:${APP_ENVIRONMENT}
### STAGE 2: Run ###
FROM nginx:alpine
COPY --from=builder /crc-bpmn/dist/cr-connect-bpmn /usr/share/nginx/html/
COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /crc-frontend/dist/* /usr/share/nginx/html/
COPY --from=builder /crc-frontend/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./substitute-env-variables.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html"]
### STAGE 3: Profit! ###
CMD ["nginx", "-g", "daemon off;"]

View File

@ -10,9 +10,9 @@ services:
environment:
- POSTGRES_USER=crc_user
- POSTGRES_PASSWORD=crc_pass
- POSTGRES_MULTIPLE_DATABASES=crc_test,crc_dev
- POSTGRES_MULTIPLE_DATABASES=crc_test,crc_dev,pb_test,pb
healthcheck:
test: ["CMD", "ping", "-h", "localhost"]
test: ["CMD", "pg_isready"]
timeout: 20s
retries: 10
@ -29,3 +29,15 @@ services:
ports:
- "5000:5000"
command: ./wait-for-it.sh db:5432 -t 0 -- ./docker_run.sh
pb:
container_name: pb
image: sartography/protocol-builder-mock
volumes:
- ./flask-config/config_pb.py:/protocol-builder-mock/instance/config.py
environment:
- FLASK_APP=/protocol-builder-mock/app.py
ports:
- "5001:5001"
command: ./wait-for-it.sh db:5432 -t 0 -- ./docker_run.sh

View File

@ -0,0 +1,11 @@
import os
basedir = os.path.abspath(os.path.dirname(__file__))
NAME = "CR Connect Protocol Builder Mock"
CORS_ENABLED = False
DEVELOPMENT = True
TESTING = True
SQLALCHEMY_DATABASE_URI = "postgresql://crc_user:crc_pass@db:5432/pb_test"
SECRET_KEY = 'a really really really really long secret key'
print('\n\n*** USING INSTANCE CONFIG ***\n\n')

View File

@ -0,0 +1,18 @@
#!/bin/bash
# The first parameter is the path to the file which should be substituted
if [[ -z $1 ]]; then
echo 'ERROR: No target file given.'
exit 1
fi
# Replace strings in the given file that have the format ${ENV_VAR}
envsubst '\$PRODUCTION \$API_URL \$IRB_URL' < "$1" > "$1".tmp && mv "$1".tmp "$1"
# Set DEBUG=true in order to log the replaced file
if [ "$DEBUG" = true ] ; then
exec cat $1
fi
# Execute all other commands with parameters
exec "${@:2}"