mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2025-12-16 05:57:48 +01:00
that work
This commit is contained in:
parent
614da05eab
commit
08493a1eef
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
||||
docker-compose.yaml
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
.env
|
||||
.git
|
||||
.gitignore
|
||||
makefile
|
||||
venv
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
.env
|
||||
|
||||
# virtualenv
|
||||
myenv/
|
||||
venv/
|
||||
|
||||
__pycache__
|
||||
|
||||
19
Dockerfile
19
Dockerfile
@ -1,7 +1,22 @@
|
||||
FROM python:3.8
|
||||
FROM python:3.12.4
|
||||
|
||||
WORKDIR /ft_transcendence
|
||||
|
||||
RUN apt update && apt upgrade -y
|
||||
RUN apt install -y vim
|
||||
|
||||
COPY requirements.txt .
|
||||
COPY manage.py .
|
||||
|
||||
RUN python3 -m venv venv
|
||||
RUN venv/bin/pip3 install --upgrade pip
|
||||
RUN venv/bin/pip3 install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
#RUN venv/bin/python3 manage.py migrate --noinput
|
||||
#RUN venv/bin/python manage.py collectstatic --noinput
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
||||
CMD ["venv/bin/python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:13
|
||||
image: postgres:16.3
|
||||
container_name: postgres
|
||||
restart: always
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
@ -25,27 +25,14 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
image: backend
|
||||
container_name: backend
|
||||
#command: python -m venv myenv && \
|
||||
# source myenv/bin/activate && \
|
||||
# pip3 install -r requirements.txt && \
|
||||
#tail -f /dev/null
|
||||
|
||||
#command: sh -c "python3 manage.py migrate --noinput && \
|
||||
# python3 manage.py collectstatic --noinput && \
|
||||
# python manage.py runserver 0.0.0.0:8000"
|
||||
|
||||
restart: always
|
||||
command: /bin/sh -c "sleep 5 && venv/bin/python3 manage.py migrate --noinput && venv/bin/python3 manage.py runserver 0.0.0.0:8000"
|
||||
volumes:
|
||||
- .:/ft_transcendence
|
||||
- helloword_project:/ft_transcendence/helloworld
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
- db
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:8000 || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- app-network
|
||||
environment:
|
||||
@ -54,6 +41,11 @@ services:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
DB_HOST: ${DB_HOST}
|
||||
DB_PORT: ${DB_PORT}
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:8000 || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
@ -62,6 +54,12 @@ volumes:
|
||||
type: none
|
||||
device: /home/motoko/data/ft_transcendence/db
|
||||
o: bind
|
||||
helloword_project:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
device: /home/motoko/Programmation/DJANGO_TEST/ft_transcendence/helloworld
|
||||
o: bind
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
|
||||
@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@ -76,12 +78,15 @@ WSGI_APPLICATION = 'helloworld.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'helloworld.db'),
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': os.getenv('POSTGRES_DB', 'default_db_name'),
|
||||
'USER': os.getenv('POSTGRES_USER', 'default_user'),
|
||||
'PASSWORD': os.getenv('POSTGRES_PASSWORD', 'default_password'),
|
||||
'HOST': os.getenv('DB_HOST', 'db'),
|
||||
'PORT': os.getenv('DB_PORT', '5432'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
||||
|
||||
|
||||
@ -16,6 +16,5 @@ def main():
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@ -1 +1,3 @@
|
||||
Django==4.2.3
|
||||
Django
|
||||
psycopg2
|
||||
python-dotenv
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user