diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9550308 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe161cd --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a92630d --- /dev/null +++ b/docker-compose.yml @@ -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: