Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/.env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0,backend
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173

# MariaDB connection (matches the db service in docker-compose.yml)
DATABASE_URL=mysql://cheatsheet_user:cheatsheet_pass@db:3306/cheatsheet_db
# PostgreSQL connection (matches the db service in docker-compose.yml)
DATABASE_URL=postgres://cheatsheet_user:cheatsheet_pass@db:5432/cheatsheet_db
6 changes: 3 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
tar \
fontconfig \
default-libmysqlclient-dev \
libpq-dev \
pkg-config \
gcc \
default-mysql-client \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

# Download and extract the appropriate Tectonic binary
Expand All @@ -35,4 +35,4 @@ COPY . .

EXPOSE 8000

CMD ["sh", "-c", "until mysqladmin ping -hdb -ucheatsheet_user -pcheatsheet_pass --ssl=0 --silent; do sleep 2; done && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]
CMD ["sh", "-c", "until pg_isready -h db -U cheatsheet_user; do sleep 2; done && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ djangorestframework>=3.15
django-cors-headers>=4.4
python-dotenv>=1.0,<2.0
dj-database-url>=2.1
mysqlclient>=2.2
psycopg2-binary>=2.9

# Testing
pytest>=8.0
Expand Down
17 changes: 8 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
services:
db:
image: mysql:8.0
image: postgres:15
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: cheatsheet_db
MYSQL_USER: cheatsheet_user
MYSQL_PASSWORD: cheatsheet_pass
POSTGRES_DB: cheatsheet_db
POSTGRES_USER: cheatsheet_user
POSTGRES_PASSWORD: cheatsheet_pass
# ports: comment out for now we'e not using atm
# - "3306:3306"
# - "5432:5432"
volumes:
- mysql_data:/var/lib/mysql
- postgres_data:/var/lib/postgresql/data
backend:
build: ./backend
ports:
- "8000:8000"
env_file:
- ./backend/.env.docker
environment:
- DATABASE_URL=mysql://cheatsheet_user:cheatsheet_pass@db:3306/cheatsheet_db
- DATABASE_URL=postgres://cheatsheet_user:cheatsheet_pass@db:5432/cheatsheet_db
volumes:
- ./backend:/app
depends_on:
Expand All @@ -41,4 +40,4 @@ services:
backend:
condition: service_healthy
volumes:
mysql_data:
postgres_data:
Loading