docker restart:unless-stopped

main
andrey 2024-02-02 12:58:47 +00:00
parent 77464b20da
commit a5ad54b655
2 changed files with 22 additions and 23 deletions

View File

@ -1,5 +1,5 @@
# Use an official Python runtime as a parent image # Use an official Python runtime as a parent image
FROM python:3.10 FROM python:3.11.7-slim-bookworm
# Set environment variables # Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONDONTWRITEBYTECODE 1
@ -13,13 +13,11 @@ WORKDIR /app
COPY . /app COPY . /app
# Install any needed packages specified in requirements.txt # Install any needed packages specified in requirements.txt
RUN pip install --upgrade pip RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt && python manage.py collectstatic --noinput
RUN pip install --no-cache-dir -r requirements.txt
RUN python manage.py collectstatic --noinput
# Copy the startup script # Copy the startup script
COPY start.sh /app/ # COPY start.sh /app/
RUN chmod +x /app/start.sh # RUN chmod +x /app/start.sh
# Make port 8000 available to the world outside this container # Make port 8000 available to the world outside this container
EXPOSE 8000 EXPOSE 8000

View File

@ -1,17 +1,18 @@
version: '3' version: '3'
services: services:
web: web:
build: . restart: unless-stopped
command: sh -c "/app/start.sh" build: .
volumes: command: sh -c "/app/start.sh"
- .:/app volumes:
- ./media:/app/media - .:/app
ports: - ./media:/app/media
- "${PORT}:8000" ports:
environment: - "${PORT}:8000"
- DEBUG=${DEBUG} environment:
- PORT=${PORT} - DEBUG=${DEBUG}
- PORT=8000
volumes:
media: volumes:
media: