Skip to content

Commit

Permalink
[env] Get dev containers working with the dev database
Browse files Browse the repository at this point in the history
  • Loading branch information
georgejkaye committed Dec 20, 2023
1 parent 673920c commit 4dcb668
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
3 changes: 3 additions & 0 deletions api/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ RUN python /app/mail/gen_msmtprc.py ${MSMTP_CONFIG_FILE} ${MSMTP_HOST} ${MSMTP_P
RUN chmod +x ${MSMTP_EVAL_SCRIPT}

COPY .env .
RUN mkdir /run/secrets
RUN echo password > /run/secrets/api_password
RUN echo password > /run/secrets/db_password

ENV CB_API_ROOT /app
ENV API_ENV dev
Expand Down
32 changes: 15 additions & 17 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ services:
environment:
POSTGRES_USER: cookies
POSTGRES_DB: cookies
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
- "5434:5432"
volumes:
- pgdata:/var/lib/postgresql/data
- ./db/init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql
secrets:
- db_password
networks:
- internal
adminer:
image: adminer
restart: always
ports:
- 8080:8080
- 8082:8080
networks:
- internal
api:
build:
context: api
Expand Down Expand Up @@ -63,6 +63,8 @@ services:
networks:
- internal
client:
depends_on:
- api
build:
context: client
dockerfile: Dockerfile.dev
Expand All @@ -73,36 +75,32 @@ services:
- "${CLIENT_PORT}:${CLIENT_PORT}"
environment:
API_URL: "http://api:${API_PORT}"
depends_on:
- api
volumes:
- ./client:/app
- ./client/node_modules:/app/node_modules
networks:
- internal
updater:
depends_on:
- api
build:
context: updater
dockerfile: Dockerfile
dockerfile: Dockerfile.dev
args:
CRON: "* * * * *"
POETRY_VERSION: ${POETRY_VERSION}
environment:
API_USER: ${API_USER}
API_USER: admin
API_PASSWORD: /run/secrets/api_password
API_ENDPOINT: "http://api:${API_PORT}"
depends_on:
- api
secrets:
- api_password
networks:
- internal
volumes:
- ./updater/src:/app/src
secrets:
api_secret:
file: ${API_SECRET_FILE}
gpg_private:
file: ${GPG_SECRET_KEY_FILE}
api_password:
file: ${API_PASSWORD_FILE}
db_password:
file: ${DB_PASSWORD_FILE}
volumes:
pgdata:
2 changes: 1 addition & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ services:
updater:
build:
context: updater
dockerfile: Dockerfile
dockerfile: Dockerfile.prod
args:
CRON: ${CRON}
POETRY_VERSION: ${POETRY_VERSION}
Expand Down
37 changes: 37 additions & 0 deletions updater/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM python:3.11-bookworm

RUN apt update
RUN apt install cron -y

ARG POETRY_VERSION=1.5.1
ARG CRON="* * * * *"

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache \
VIRTUAL_ENV=/app/.venv \
PATH=/app/.venv/vin:$PATH \
PYTHONPATH=/app/src:$PYTHONPATH

RUN pip install poetry==${POETRY_VERSION}

WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN touch README.md
RUN poetry install --no-root

COPY src ./src
RUN poetry install

RUN mkdir /run/secrets
RUN echo password > /run/secrets/api_password
RUN echo password > /run/secrets/db_password
RUN echo "${CRON} cd /app && /usr/local/bin/poetry run python /app/src/updater/main.py > /tmp/stdout 2> /tmp/stderr" > crontab
RUN crontab crontab

COPY entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh

CMD [ "./entrypoint.sh" ]

File renamed without changes.

0 comments on commit 4dcb668

Please sign in to comment.