Skip to content

Commit

Permalink
feat(docker): add docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxin688 committed Jun 16, 2024
1 parent 7f5cda2 commit a326bfb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ DEFAULT_DB_USER=demo
DEFAULT_DB_NAME=demo
DEFAULT_DB_PORT=5432

MQ_AMQP_PORT=5672
MQ_MGMT_PORT=15672
MQ_DEFAULT_USER=demo
MQ_DEFAULT_PASS=91fb8e9e009f5b9ce1854d947e6fe4a3

REDIS_DEFAULT_PASS=cfe1c2c4703abb205d71abdc07cc3f3d
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.12-slim-bullseye as base

FROM base AS install

WORKDIR /home/app
ENV PYTHONPATH=/home/app PYTHONHASHSEED=0


COPY alembic.ini .env requirements.lock pyproject.toml README.md ./
COPY src/ src/
COPY alembic/ alembic/
RUN chmod 755 .env
RUN PYTHONDONTWRITEBYTECODE=1 pip install -r requirements.lock
RUN alembic upgrade head

CMD ["python", "src/__main__.py"]
2 changes: 1 addition & 1 deletion alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from src.core import config as app_config
from src.core.models.base import Base
from src.features.auth.models import * # noqa: F403
from src.features.admin.models import * # noqa: F403


# this is the Alembic Config object, which provides
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
- .env
postgres:
image: postgres:latest
restart: unless-stopped
container_name: "postgres"
ports:
- "${DEFAULT_DB_PORT}:5432"
volumes:
Expand All @@ -22,3 +24,32 @@ services:
- POSTGRES_DB=${DEFAULT_DB_NAME}
env_file:
- .env

rabbitmq:
image: rabbitmq:3.13.3-management
container_name: "rabbitmq"
restart: unless-stopped
ports:
- "${MQ_AMQP_PORT}:5672"
- "${MQ_MGMT_PORT}:15672"
volumes:
- ./data/rabbitmq:/var/lib/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=${MQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${MQ_DEFAULT_PASS}
env_file:
- .env
# app:
# depends_on:
# - redis
# - postgres
# - rabbitmq
# build:
# context: .
# dockerfile: ./Dockerfile
# container_name: "app"
# restart: unless-stopped
# ports:
# - "${APP_PORT}:8000"
# volumes:
# - ./data/app:/var/lib/app

0 comments on commit a326bfb

Please sign in to comment.