forked from alphaonelabs/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (37 loc) · 1.39 KB
/
Dockerfile
File metadata and controls
50 lines (37 loc) · 1.39 KB
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
49
50
# Python base image
FROM python:3.10-slim@sha256:f9fd9a142c9e3bc54d906053b756eb7e7e386ee1cf784d82c251cf640c502512
# Set working directory
WORKDIR /app
# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy only dependency manifests first (better layer caching)
COPY pyproject.toml poetry.lock* ./
# Install Poetry and project dependencies (system deps minimal here; app build image)
RUN python -m pip install --upgrade pip wheel setuptools && \
pip install poetry==1.8.3 && \
poetry config virtualenvs.create false --local || true && \
poetry install --only main --no-interaction --no-ansi
# Copy project files
COPY . .
# Create necessary directories for static files
RUN mkdir -p /app/static /app/staticfiles
# Create and configure environment variables
COPY .env.sample .env
# Collect static files
RUN python manage.py collectstatic --noinput
# Run migrations and create test data
RUN python manage.py migrate && \
python manage.py create_test_data
# Create superuser
ENV DJANGO_SUPERUSER_USERNAME=admin
ENV DJANGO_SUPERUSER_EMAIL=admin@example.com
ENV DJANGO_SUPERUSER_PASSWORD=adminpassword
RUN python manage.py createsuperuser --noinput
# Echo message during build
RUN echo "Your Project is now live on http://localhost:8000"
# Expose port
EXPOSE 8000
# Start the server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]