Skip to content

Commit

Permalink
Refactor Dockerfiles to use one arg for frontend and backend. For far…
Browse files Browse the repository at this point in the history
  • Loading branch information
paul121 committed Jan 31, 2020
1 parent 1623713 commit f63abf1
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ NGINX_WORKER_CONNECTIONS=1024
DOCKER_IMAGE_BACKEND=backend
DOCKER_IMAGE_CELERYWORKER=celeryworker
DOCKER_IMAGE_FRONTEND=frontend

AGGREGATOR_OPEN_FARM_REGISTRATION=false
AGGREGATOR_INVITE_FARM_REGISTRATION=false
6 changes: 6 additions & 0 deletions backend/backend.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7

RUN pip install celery~=4.3 passlib[bcrypt] tenacity requests emails "fastapi==0.47.1" "pydantic==1.4" uvicorn gunicorn pyjwt python-multipart email_validator jinja2 psycopg2-binary alembic SQLAlchemy "farmOS==0.1.5"

# Load farm registration configuration.
ARG OPEN_FARM_REGISTRATION
ARG INVITE_FARM_REGISTRATION
ENV AGGREGATOR_OPEN_FARM_REGISTRATION=${OPEN_FARM_REGISTRATION}
ENV AGGREGATOR_INVITE_FARM_REGISTRATION=${INVITE_FARM_REGISTRATION}

# For development, Jupyter remote kernel, Hydrogen
# Using inside the container:
# jupyter notebook --ip=0.0.0.0 --allow-root
Expand Down
6 changes: 6 additions & 0 deletions backend/celeryworker.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ FROM python:3.7

RUN pip install raven celery~=4.3 passlib[bcrypt] tenacity requests "fastapi==0.47.1" "pydantic==1.4" emails pyjwt email_validator jinja2 psycopg2-binary alembic SQLAlchemy "farmOS==0.1.5"

# Load farm registration configuration.
ARG OPEN_FARM_REGISTRATION
ARG INVITE_FARM_REGISTRATION
ENV AGGREGATOR_OPEN_FARM_REGISTRATION=${OPEN_FARM_REGISTRATION}
ENV AGGREGATOR_INVITE_FARM_REGISTRATION=${INVITE_FARM_REGISTRATION}

# For development, Jupyter remote kernel, Hydrogen
# Using inside the container:
# jupyter notebook --ip=0.0.0.0 --allow-root
Expand Down
6 changes: 6 additions & 0 deletions backend/tests.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ FROM python:3.7

RUN pip install requests pytest tenacity passlib[bcrypt] celery~=4.3 "fastapi==0.47.1" "pydantic==1.4" pyjwt psycopg2-binary SQLAlchemy "farmOS==0.1.5"

# Load farm registration configuration.
ARG OPEN_FARM_REGISTRATION
ARG INVITE_FARM_REGISTRATION
ENV AGGREGATOR_OPEN_FARM_REGISTRATION=${OPEN_FARM_REGISTRATION}
ENV AGGREGATOR_INVITE_FARM_REGISTRATION=${INVITE_FARM_REGISTRATION}

# For development, Jupyter remote kernel, Hydrogen
# Using inside the container:
# jupyter notebook --ip=0.0.0.0 --allow-root
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.shared.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
version: '3.3'
services:
frontend:
build:
args:
OPEN_FARM_REGISTRATION: ${AGGREGATOR_OPEN_FARM_REGISTRATION}
INVITE_FARM_REGISTRATION: ${AGGREGATOR_INVITE_FARM_REGISTRATION}
backend:
depends_on:
- db
env_file:
- env-postgres.env
- env-backend.env
build:
args:
OPEN_FARM_REGISTRATION: ${AGGREGATOR_OPEN_FARM_REGISTRATION}
INVITE_FARM_REGISTRATION: ${AGGREGATOR_INVITE_FARM_REGISTRATION}
celeryworker:
depends_on:
- db
Expand Down
2 changes: 0 additions & 2 deletions env-backend.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ USERS_OPEN_REGISTRATION=False

SENTRY_DSN=

AGGREGATOR_INVITE_FARM_REGISTRATION=true
AGGREGATOR_OPEN_FARM_REGISTRATION=true
FARM_ACTIVE_AFTER_REGISTRATION=true
4 changes: 0 additions & 4 deletions frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ VUE_APP_NAME=farmOS-aggregator
VUE_APP_ENV=development
# VUE_APP_ENV=staging
# VUE_APP_ENV=production

# Configure how users can join the aggregator
VUE_APP_OPEN_FARM_REGISTRATION=false
VUE_APP_INVITE_FARM_REGISTRATION=false
14 changes: 14 additions & 0 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
VUE_APP_DOMAIN_DEV=localhost
# VUE_APP_DOMAIN_DEV=local.dockertoolbox.tiangolo.com
# VUE_APP_DOMAIN_DEV=localhost.tiangolo.com
# VUE_APP_DOMAIN_DEV=dev.localhost
VUE_APP_DOMAIN_STAG=stag.localhost
VUE_APP_DOMAIN_PROD=localhost
VUE_APP_NAME=farmOS-aggregator
VUE_APP_ENV=development
# VUE_APP_ENV=staging
# VUE_APP_ENV=production

# Add aggregator config vars for local development
VUE_APP_OPEN_FARM_REGISTRATION=true
VUE_APP_INVITE_FARM_REGISTRATION=true
6 changes: 6 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ ARG FRONTEND_ENV=production

ENV VUE_APP_ENV=${FRONTEND_ENV}

# Load farm registration configuration.
ARG OPEN_FARM_REGISTRATION
ARG INVITE_FARM_REGISTRATION
ENV VUE_APP_OPEN_FARM_REGISTRATION=${OPEN_FARM_REGISTRATION}
ENV VUE_APP_INVITE_FARM_REGISTRATION=${INVITE_FARM_REGISTRATION}

# Comment out the next line to disable tests
RUN npm run test:unit

Expand Down

0 comments on commit f63abf1

Please sign in to comment.