Skip to content

Instantly share code, notes, and snippets.

@sh1mu7
Created September 7, 2023 20:56
Show Gist options
  • Save sh1mu7/45b48bd06f0944fca10d5e6088861a2b to your computer and use it in GitHub Desktop.
Save sh1mu7/45b48bd06f0944fca10d5e6088861a2b to your computer and use it in GitHub Desktop.
Docket basic configuration
# docker-compose ym
version: '3'
services:
# Django application
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
volumes:
- .:/inventory
depends_on:
- db
environment:
DEBUG: 0
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
# PostgresSQL database
db:
image: postgres:latest
volumes:
- postgresql_data:/var/lib/postgresql
environment:
POSTGRES_DB: db_name
POSTGRES_USER: db_user_name
POSTGRES_PASSWORD: db_password
# Redis service
redis:
image: redis:latest
volumes:
- redis_data:/data # Mount a volume to persist Redis data
command: ["redis-server"]
volumes:
postgresql_data:
driver: local
redis_data:
driver: local
FROM python:3.11.4-slim-buster
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set the working directory in the container
WORKDIR /inventory
# Install Python dependencies
COPY requirements.txt /inventory/
RUN pip install -r requirements.txt
# Copy the Django project into the container
COPY . /inventory/
# Expose the port the application will run on
EXPOSE 8000
# Start the application
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
# Copy the entrypoint script into the container
COPY entrypoint.sh /entrypoint.sh
# Make the entrypoint script executable
RUN chmod +x /entrypoint.sh
# Define the entrypoint
ENTRYPOINT ["/entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment