Add docker

This commit is contained in:
Peter Vacho 2024-12-29 17:08:13 +01:00
parent 8000087896
commit d7cac9813b
Signed by: school
GPG key ID: 8CFC3837052871B4
3 changed files with 54 additions and 0 deletions

12
.dockerignore Normal file
View file

@ -0,0 +1,12 @@
# vi: ft=gitignore
# Exclude everything
*
# Make exceptions for what's needed
!src
!requirements.lock
!requirements-dev.lock
!pyproject.toml
!LICENSE.txt
!README.md

16
Dockerfile Normal file
View file

@ -0,0 +1,16 @@
FROM python:3.12-slim-bookworm
RUN pip install --no-cache-dir uv
WORKDIR /app
COPY pyproject.toml README.md LICENSE.txt requirements.lock ./
RUN uv pip install --no-cache --system -r requirements.lock
# Copy the rest of the files last, to optimize rebuilds
COPY . .
EXPOSE 8000
ENTRYPOINT ["uvicorn"]
CMD ["--host", "0.0.0.0", "--port", "8000", "src.__init__:app"]

26
docker-compose.yml Normal file
View file

@ -0,0 +1,26 @@
services:
mongodb:
image: mongo:7
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password123
networks:
- net
api:
build:
context: .
depends_on:
- mongodb
ports:
- "8000:8000"
env_file:
- .env
environment:
MONGODB_URI: mongodb://root:password123@mongodb:27017/db?authSource=admin
networks:
- net
- default
networks:
net: