This commit is contained in:
2024-11-04 20:21:39 +11:00
parent 1474c5828b
commit 04d89b53cc
2 changed files with 29 additions and 3 deletions
+13 -3
View File
@@ -1,11 +1,12 @@
FROM ghcr.io/astral-sh/uv:bookworm-slim AS uv
FROM python:3.12-slim
FROM python:3.12 as dev
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /app
ENV UV_CACHE_DIR /app/.cache/uv
# Set work directory
WORKDIR /app
@@ -25,10 +26,12 @@ RUN apt-get update && apt-get install -y \
COPY --from=uv /usr/local/bin/uv /usr/local/bin/uv
# Create cache directory with proper permissions
RUN mkdir -p /app/.cache/uv && chmod -R 777 /app/.cache
RUN which uv \
&& uv sync --no-dev
# Copy project
COPY . .
@@ -42,7 +45,14 @@ RUN uv run manage.py collectstatic --noinput
RUN uv run manage.py compilemessages --locale=zh_Hans
# Create data directory for SQLite database
RUN mkdir -p /app/data && chmod 777 /app/data
FROM python:3.12-slim
COPY --from=uv /usr/local/bin/uv /usr/local/bin/uv
COPY --from=dev /app /app
WORKDIR /app
# Expose port 8000
EXPOSE 8000
# Run the application
CMD ["uv", "run", "gunicorn", "--chdir", "/app", "url_manager.wsgi:application", "--bind", "0.0.0.0:8000"]
CMD ["uv", "run", "gunicorn", "--chdir", "/app", "core.wsgi:application", "--bind", "0.0.0.0:8000"]
+16
View File
@@ -33,6 +33,8 @@ spec:
- name: data
persistentVolumeClaim:
claimName: links-pvc
- name: cache
emptyDir: {}
initContainers:
- name: links-init
image: "ghcr.io/wahyd4/links:main"
@@ -49,6 +51,8 @@ spec:
volumeMounts:
- name: data
mountPath: /app/data
- name: cache
mountPath: /app/.cache
env:
- name: DB_HOST
value: new-postgres-postgresql.db.svc.cluster.local
@@ -65,6 +69,8 @@ spec:
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: CELERY_RESULT_BACKEND
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: UV_CACHE_DIR
value: "/app/.cache/uv"
ports:
- containerPort: 8000
name: links-port
@@ -180,6 +186,8 @@ spec:
- name: data
persistentVolumeClaim:
claimName: links-pvc
- name: cache
emptyDir: {}
containers:
- name: celery-worker
image: "ghcr.io/wahyd4/links:main"
@@ -190,6 +198,8 @@ spec:
volumeMounts:
- name: data
mountPath: /app/data
- name: cache
mountPath: /app/.cache
env:
- name: DB_HOST
value: new-postgres-postgresql.db.svc.cluster.local
@@ -201,6 +211,8 @@ spec:
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: CELERY_RESULT_BACKEND
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: UV_CACHE_DIR
value: "/app/.cache/uv"
resources:
requests:
cpu: 100m
@@ -218,6 +230,8 @@ spec:
volumeMounts:
- name: data
mountPath: /app/data
- name: cache
mountPath: /app/.cache
env:
- name: DB_HOST
value: new-postgres-postgresql.db.svc.cluster.local
@@ -229,6 +243,8 @@ spec:
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: CELERY_RESULT_BACKEND
value: "redis://redis-master.db.svc.cluster.local:6379"
- name: UV_CACHE_DIR
value: "/app/.cache/uv"
resources:
requests:
cpu: 100m