-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prod docker file for middleware (#6)
- Loading branch information
1 parent
efbaf37
commit 9540fb9
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Stage 1: Build stage | ||
FROM python:3.12-slim-bookworm AS builder | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PATH /venv/bin:$PATH | ||
|
||
# Create virtual environment | ||
RUN python -m venv /venv | ||
|
||
# Install pipenv and dependencies | ||
RUN pip install --no-cache-dir pipenv | ||
|
||
# Copy Pipfile and Pipfile.lock for dependency installation | ||
COPY Pipfile Pipfile.lock ./ | ||
|
||
# Install only production dependencies | ||
RUN pipenv install --system --deploy --ignore-pipfile | ||
|
||
# Stage 2: Production stage | ||
FROM python:3.12-slim-bookworm | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PATH /venv/bin:$PATH | ||
|
||
# Copy virtual environment from the builder stage | ||
COPY --from=builder /venv /venv | ||
|
||
# Copy the application code | ||
COPY . /app | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Expose the application port | ||
EXPOSE 8090 | ||
|
||
|
||
CMD ["python", "manage.py" , "runserver" , "0.0.0.0:8090"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Navigate to the app directory | ||
cd /app | ||
|
||
# Run migrations | ||
python manage.py migrate | ||
|
||
# Start Celery worker | ||
celery -A middleware.celery worker -B --loglevel=info |