File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ FROM python:3.11-slim
3535ENV PYTHONDONTWRITEBYTECODE=1
3636ENV PYTHONUNBUFFERED=1
3737
38+ RUN apt-get update \
39+ && apt-get install -y --no-install-recommends \
40+ git \
41+ openssh-client \
42+ && rm -rf /var/lib/apt/lists/*
43+
3844# Create a non-root user and group for security
3945RUN groupadd --system appuser || true && useradd --system -g appuser appuser
4046
@@ -46,6 +52,9 @@ ENV PATH="/opt/venv/bin:$PATH"
4652
4753WORKDIR /app
4854
55+ # Create data directories needed by the application
56+ RUN mkdir -p /app/data/user_files /app/data/cloned_repos
57+
4958# Copy application code, ensuring it's owned by the non-root user
5059COPY --chown=appuser:appuser ./api/app .
5160COPY --chown=appuser:appuser ./api/alembic.ini .
@@ -55,9 +64,5 @@ COPY --chown=appuser:appuser ./api/migrations ./migrations
5564ENV API_PORT=8000
5665EXPOSE 8000
5766
58- # Switch to the non-root user
59- USER appuser
60-
6167# Use the shell form of CMD to allow environment variable substitution.
62- # This fixes the syntax error in the original CMD.
6368CMD gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:${API_PORT}
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ services:
2828 image : ghcr.io/mathisverstrepen/meridian/backend:${IMAGE_TAG:-latest}
2929
3030 container_name : ${NAME}_api
31- command : sh -c "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port ${API_PORT}"
31+ command : sh -c "chown -R appuser:appuser /app/data && su appuser -c ' alembic upgrade head && gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0: ${API_PORT}' "
3232 ports :
3333 - " ${API_PORT}:${API_PORT}"
3434 depends_on :
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ services:
3232 context : ..
3333 dockerfile : docker/api.Dockerfile
3434 container_name : ${NAME}_api
35- command : sh -c "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port ${API_PORT}"
35+ command : sh -c "chown -R appuser:appuser /app/data && su appuser -c ' alembic upgrade head && gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0: ${API_PORT}' "
3636 ports :
3737 - " ${API_PORT}:${API_PORT}"
3838 depends_on :
You can’t perform that action at this time.
0 commit comments