rafaelrodriguess/social-network

By rafaelrodriguess

Updated 1 day ago

Image
Languages & frameworks
Web servers
1

1.4K

rafaelrodriguess/social-network repository overview

Social Network App - Rafael Rodrigues

Docker Image Size Python Version

This is the official image for the Social Network application, a web application built with Django (Python). The image was built in an optimized way using python:3.13-alpine, ensuring it is lightweight and secure, making it ideal for production environments.

🚀 About this Image

The image packages all the application code and its dependencies, ready for execution. It is configured with Docker best practices:

  • Runs the application via the entrypoint.sh script (responsible for migrations and starting the WSGI/ASGI server).
  • Exposes port 8000.
  • Securely manages static and media files (with configurable support for S3 buckets, such as Supabase).
  • Runs the process with a non-root user (duser), ensuring greater security.

🛠️ How to use this image (Docker Compose)

Since the application requires a relational database (PostgreSQL), the easiest and recommended way to start the services is by using Docker Compose.

Create a docker-compose.yml file and add the following content:

services:
  db:
    image: postgres:17
    volumes:
      - db_socialnet:/var/lib/postgresql/data
    env_file:
      - .env
    networks:
      - socialnet-network

  web:
    image: rafaelrodriguess/social-network:latest
    ports:
      - "8000:8000"
    volumes:
      - static_volume:/data/web/static
      - media_volume:/data/web/media
    env_file:
      - .env
    networks:
      - socialnet-network
    depends_on:
      - db

networks:
  socialnet-network:

volumes:
  db_socialnet:
  static_volume:
  media_volume:

⚙️ Environment Variables (.env)

The image is highly configurable through environment variables. Create a .env file in the same folder as your docker-compose.yml with the following configuration:

# Django Configurations
SECRET_KEY="your-super-secure-secret-key"
DEBUG=0
ALLOWED_HOSTS=127.0.0.1,localhost,your-domain.com
CSRF_TRUSTED_ORIGINS=http://localhost,https://your-domain.com
PER_PAGE=10

# Database Configurations (PostgreSQL)
POSTGRES_DB="socialnet_db"
POSTGRES_USER="postgres_user"
POSTGRES_PASSWORD="postgres_password"
POSTGRES_HOST="db" # Database service name in docker-compose
POSTGRES_PORT="5432"

# S3 Storage Credentials (e.g. Supabase) for Media
SUPABASE_STORAGE_BUCKET_NAME="your-bucket"
SUPABASE_ACCESS_KEY_ID="your-access-key"
SUPABASE_SECRET_ACCESS_KEY="your-secret-key"
SUPABASE_ENDPOINT_URL="your-endpoint-url"

📂 Internal Volumes

The image uses specific directories to persist volatile data. It is highly recommended to map them to named volumes (as shown in the Docker Compose example):

  • /data/web/static: Collected static files from the application (CSS, JS, fonts).
  • /data/web/media: Media files uploaded by users in the system.

🔒 Security and Performance Focus

This image was designed for production:

  • Alpine Linux Base: Drastically reduces the final image size and the surface for potential attacks.
  • Non-root user: Prevents the application from running as root, limiting internal access within the container.
  • Python Optimization: Environment variables like PYTHONDONTWRITEBYTECODE=1 and PYTHONUNBUFFERED=1 are enabled by default to ensure logs are output quickly and temporary files do not pollute the container.

Developed by Rafael Rodrigues.

Tag summary

Content type

Image

Digest

sha256:8719074f1

Size

89 MB

Last updated

1 day ago

docker pull rafaelrodriguess/social-network