-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dockerfiles so that it automatically spins up celery and redis…
… in dev env
- Loading branch information
1 parent
f51680c
commit c76b53d
Showing
9 changed files
with
137 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
## Run docker | ||
From the training/ directory | ||
Dev: docker-compose up | ||
Production: docker-compose -f docker-compose.prod.yml up | ||
Ensure you have logged in to AWS, using (`aws configure sso`) then (`aws sso login --profile=DLP`) | ||
|
||
## Rebuild and run docker | ||
From the training/ directory | ||
Dev: docker-compose up --build | ||
Production: docker-compose -f docker-compose.prod.yml up --build | ||
Dev: `AWS_PROFILE=DLP docker-compose up` | ||
Production: `AWS_PROFILE=DLP docker compose -f docker-compose.prod.yml up` | ||
|
||
To rebuild, add a --build flag to the command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
version: '3.8' | ||
version: "3.8" | ||
|
||
services: | ||
web: | ||
build: | ||
dockerfile: Dockerfile.prod | ||
context: . | ||
target: production | ||
volumes: | ||
- ./:/usr/src/training/ | ||
- $HOME/.aws/credentials:/home/app/.aws/credentials:ro | ||
- $HOME/.aws:/home/app/.aws:ro | ||
ports: | ||
- 8000:8000 | ||
environment: | ||
- AWS_PROFILE=$AWS_PROFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
broker_url = "sqs://" # "redis://localhost:6379" | ||
import os | ||
|
||
broker_transport_options = { | ||
"predefined_queues": { | ||
"training-queue.fifo": { | ||
"url": "https://sqs.us-east-1.amazonaws.com/521654603461/training-queue.fifo", | ||
# note, this file is used both in training/ and in the celery worker | ||
if "ENVIRONMENT" in os.environ and os.environ["ENVIRONMENT"] == "production": | ||
print( | ||
"ENVIRONMENT env var set to production, setting broker_url to sqs training-queue" | ||
) | ||
broker_url = "sqs://" | ||
|
||
broker_transport_options = { | ||
"predefined_queues": { | ||
"training-queue.fifo": { | ||
"url": "https://sqs.us-east-1.amazonaws.com/521654603461/training-queue.fifo", | ||
} | ||
} | ||
} | ||
} | ||
|
||
task_default_queue = "training-queue.fifo" | ||
task_default_queue = "training-queue.fifo" | ||
else: | ||
print( | ||
"ENVIRONMENT env var either not found or not set to production, setting broker_url to redis://redis:6379" | ||
) | ||
broker_url = "redis://redis:6379" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM condaforge/miniforge3 AS base | ||
|
||
WORKDIR /usr/src/build | ||
|
||
# install dependencies | ||
RUN mamba create --name dlp -y | ||
|
||
COPY environment.yml pyproject.toml poetry.lock ./ | ||
RUN mamba run --live-stream -n dlp mamba env update --file environment.yml --prune | ||
|
||
# create directory for the app user | ||
RUN mkdir -p /home/app | ||
|
||
# create the app user | ||
RUN addgroup --system app && adduser --system --group app | ||
|
||
# create the appropriate directories | ||
ARG HOME=/home/app | ||
ARG APP_HOME=/home/app/training | ||
RUN mkdir $APP_HOME | ||
|
||
|
||
|
||
######################## development target ######################## | ||
FROM base AS development | ||
ENV ENVIRONMENT development | ||
|
||
RUN mamba run --live-stream -n dlp poetry install | ||
|
||
|
||
# we previously mounted training/ to APP_HOME | ||
WORKDIR $APP_HOME | ||
RUN chown -R app:app $APP_HOME | ||
USER app | ||
|
||
CMD mamba run --live-stream -n dlp celery -A training.core.celery.worker worker --loglevel=INFO | ||
|
||
######################## production target ######################### | ||
FROM base AS production | ||
ENV ENVIRONMENT production | ||
|
||
RUN mamba run --live-stream -n dlp poetry install --without dev | ||
|
||
# copy project | ||
WORKDIR $APP_HOME | ||
COPY . $APP_HOME | ||
|
||
RUN chown -R app:app $APP_HOME | ||
USER app | ||
|
||
CMD mamba run --live-stream -n dlp celery -A training.core.celery.worker worker --loglevel=INFO |