-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (36 loc) · 1.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# First stage: Build environment for Tailwind CSS
FROM node:16-slim AS build
WORKDIR /app
COPY package.json package-lock.json /app/
RUN npm install
COPY . /app/
RUN npm run build
# Second stage: Combined Python and Nginx environment
FROM python:3.13-slim
# Set the working directory inside the container
WORKDIR /app
# Install system dependencies for Nginx, PostgreSQL, and Python
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc libpq-dev nginx \
&& apt-get clean
# Install Python dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip && pip install -r requirements.txt
# Copy the rest of the application files
COPY . /app/
# Copy static files generated from the build stage
COPY --from=build /app/static /app/static
# Collect static files (ensure the static folder is correctly set)
RUN python manage.py collectstatic --noinput --verbosity 2
# Copy the Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Create a new user and group for Nginx
RUN addgroup --system nginx && adduser --system --ingroup nginx nginx
# Ensure the entrypoint script is accessible and executable
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Expose the required port for Nginx
EXPOSE 80
# Start Gunicorn and Nginx via the entrypoint script
CMD ["/app/entrypoint.sh"]