Skip to content

Commit

Permalink
Optimize Dockerfile (#34)
Browse files Browse the repository at this point in the history
* Reduce docker file by using python:3.8-slim-buster
image-size reduction 1.27GB -> 484 MB

* fix crash error with restart-flag

* move db_data to a separate docker volume
  • Loading branch information
kahlstrm authored Apr 17, 2023
1 parent fb8a33b commit 6ee1042
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM python:3.8 as base
FROM python:3.8-slim-buster as base

# Setup ENV variables here (if needed in the future)

Expand All @@ -15,8 +15,11 @@ COPY Pipfile.lock .
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy


FROM base as runtime

FROM base
# install postgres driver
RUN apt update && \
apt install libpq-dev -y && \
rm -rf /var/lib/apt/lists/*
# Copy virtual env from python-deps stage
COPY --from=python-deps /.venv /.venv
ENV PATH="/.venv/bin:$PATH"
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ services:
build:
context: .
dockerfile: dev.Dockerfile
restart: on-failure
volumes:
- ./kipubot:/bot/kipubot
- kipubot_db:/bot/kipubot
env_file:
- .env
environment:
- DATABASE_URL=postgresql://username:password@database:5432
depends_on:
- database
volumes:
kipubot_db:

0 comments on commit 6ee1042

Please sign in to comment.