Skip to content

Commit 7e7821a

Browse files
committed
feat: add Docker support
1 parent 920154d commit 7e7821a

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.env
2+
.venv
3+
__pycache__
4+
node_modules
5+
data/

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.13-slim AS builder
2+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
3+
4+
WORKDIR /app
5+
6+
# Install dependencies
7+
RUN --mount=type=cache,target=/root/.cache/uv \
8+
--mount=type=bind,source=uv.lock,target=uv.lock \
9+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
10+
uv sync --frozen --no-install-project --no-editable
11+
12+
# Copy the project into the intermediate image
13+
ADD . /app
14+
15+
# Sync the project
16+
RUN --mount=type=cache,target=/root/.cache/uv \
17+
uv sync --frozen --no-editable
18+
19+
FROM python:3.13-slim
20+
COPY --from=builder --chown=app:app /app /app
21+
22+
WORKDIR /app
23+
24+
CMD ["/app/.venv/bin/litestar", "run", "--host=0.0.0.0"]

docker-compose.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: which-class
2+
services:
3+
which-class:
4+
build: .
5+
restart: always
6+
ports:
7+
- 8000:8000
8+
environment:
9+
- MONGO_URI=mongodb://root:root@mongo:27017/
10+
- MONGO_DB=2025Spring
11+
- TZ=Asia/Shanghai
12+
13+
mongo:
14+
image: mongo
15+
restart: always
16+
ports:
17+
- 27017:27017
18+
volumes:
19+
- mongo-data:/data/db
20+
environment:
21+
MONGO_INITDB_ROOT_USERNAME: root
22+
MONGO_INITDB_ROOT_PASSWORD: root
23+
24+
volumes:
25+
mongo-data:

0 commit comments

Comments
 (0)