Skip to content

Commit

Permalink
chore: use dev flag, rather than prod flag
Browse files Browse the repository at this point in the history
  • Loading branch information
xgui3783 committed Jul 18, 2021
1 parent 6d8475c commit e2d2985
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/docker-img.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:
if [ "$GITHUB_EVENT_NAME" = "push" ]
then
# since it's latest, set DEV_FLAG to true
echo "DEV_FLAG=1" >> $GITHUB_ENV
DOCKER_IMAGE_TAG=latest
fi
if [ "$GITHUB_EVENT_NAME" = "release" ]
then
# since it's release, set PROD_FLAG to true
echo "PROD_FLAG=1" >> $GITHUB_ENV
if [[ "$GITHUB_REF" = *"rc"* ]]
then
# if release contains rc, set img tag to rc
Expand All @@ -54,16 +54,16 @@ jobs:
run: |
DOCKER_BUILT_TAG=${{ env.DOCKER_REGISTRY }}${{ env.DOCKER_IMG }}:$DOCKER_IMAGE_TAG
echo "Building $DOCKER_BUILT_TAG"
if [ -z "$PROD_FLAG" ]
if [ -z "$DEV_FLAG" ]
then
echo "PROD_FLAG not set, build latest"
echo "DEV_FLAG not set, build latest"
docker build \
-t $DOCKER_BUILT_TAG \
.
else
echo "PROD_FLAG set, build for prod"
echo "DEV_FLAG set, build for prod"
docker build \
--build-arg PROD_FLAG=1 \
--build-arg DEV_FLAG=1 \
-t $DOCKER_BUILT_TAG \
.
fi
Expand Down Expand Up @@ -94,6 +94,11 @@ jobs:
if [ "$GITHUB_EVENT_NAME" = "push" ]
then
echo "event triggered is 'push', use dev envvar"
# since it's release, set DEV_FLAG to true
echo "DEV_FLAG=1" >> $GITHUB_ENV
echo "event triggered is 'push', use develop envvar"
OKD_ENDPOINT=${{ env.OKD_DEV_ENDPOINT }}
OKD_SECRET=${{ env.OKD_DEV_SECRET }}
Expand All @@ -104,9 +109,6 @@ jobs:
if [ "$GITHUB_EVENT_NAME" = "release" ]
then
echo "event triggered is 'reelease', use prod envvar"
# since it's release, set PROD_FLAG to true
echo "PROD_FLAG=1" >> $GITHUB_ENV
OKD_ENDPOINT=${{ env.OKD_PROD_ENDPOINT }}
OKD_SECRET=${{ env.OKD_PROD_SECRET }}
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ WORKDIR /app

RUN python -m pip install -U pip

# can be passed in via --build-arg PROD_FLAG=1
ARG PROD_FLAG
# can be passed in via --build-arg DEV_FLAG=1
ARG DEV_FLAG
# if prod flag is set, set DEPLOY_ENVIRONMENT=production
ENV DEPLOY_ENVIRONMENT=${PROD_FLAG:+production}
ENV DEPLOY_ENVIRONMENT=${DEV_FLAG:+develop}
ENV DEPLOY_ENVIRONMENT=${DEPLOY_ENVIRONMENT:-production}
# if prod flag is NOT set, set SIIBRA_CONFIG_GITLAB_PROJECT_TAG=develop
ENV SIIBRA_CONFIG_GITLAB_PROJECT_TAG=${PROD_FLAG:-develop}
ENV SIIBRA_CONFIG_GITLAB_PROJECT_TAG=${DEV_FLAG:-develop}

RUN if [ "$DEPLOY_ENVIRONMENT" = "production" ]; \
then python -m pip install -r requirements/prod.txt; \
Expand Down
3 changes: 3 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: '3'
services:
app:
build:
args:
DEV_FLAG: 1
volumes:
- ./:/app
entrypoint: "uvicorn app.app:app --host 0.0.0.0 --port 5000 --reload"
6 changes: 0 additions & 6 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
version: '3'
services:
app:
build:
args:
PROD_FLAG: 1

0 comments on commit e2d2985

Please sign in to comment.