docker compose (Ready) :

- nginx
       - proxy_pass on port 5000
       - static available at url "xxxx/static/<file>
   - djangoserver
       - just a program with infinite while for test docker-compose
   Nginx and Djangoserv containers linked with the folder at "/var/wwww/djangoserver"
This commit is contained in:
Kum1ta
2024-07-28 13:25:38 +02:00
parent fcf60335a5
commit d27ab24c5e
7 changed files with 67 additions and 7 deletions

42
srcs/docker-compose.yml Normal file
View File

@ -0,0 +1,42 @@
version: '3'
services:
nginx:
container_name: nginx
volumes:
- djangoserver:/var/www/djangoserver
networks:
- transcendence
depends_on:
- djangoserver
build:
context: requirements/nginx
dockerfile: Dockerfile
ports:
- "443:443"
restart: on-failure
djangoserver:
container_name: djangoserver
volumes:
- djangoserver:/var/www/djangoserver
networks:
- transcendence
build:
context: requirements/djangoserver
dockerfile: Dockerfile
restart: on-failure
expose:
- "9000"
volumes:
djangoserver:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/edbernar/data/djangoserver'
networks:
transcendence:
driver: bridge

View File

@ -0,0 +1,18 @@
FROM debian:buster
RUN apt update && apt upgrade -y
RUN apt install -y python
RUN apt install -y python3-pip
RUN pip3 install django
RUN mkdir -p /var/www/djangoserver/
RUN mkdir -p /var/www/djangoserver/static/
COPY file/server /var/www/djangoserver/server
RUN chmod 755 /var/www/djangoserver/
RUN chown -R www-data:www-data /var/www/djangoserver/
WORKDIR /var/www/djangoserver
ENTRYPOINT [ "python", "/var/www/djangoserver/server/main.py" ]

View File

@ -0,0 +1,5 @@
import time
while True:
print("Update")
time.sleep(20)

View File

@ -3,9 +3,4 @@ FROM nginx:latest
RUN mkdir -p /etc/nginx/ssl RUN mkdir -p /etc/nginx/ssl
RUN apt install -y openssl RUN apt install -y openssl
RUN openssl req -x509 -nodes -out /etc/nginx/ssl/inception.crt -keyout /etc/nginx/ssl/inception.key -subj "/C=FR/ST=IDF/L=Paris/O=42/OU=42/CN=ptme.com/UID=ptme" RUN openssl req -x509 -nodes -out /etc/nginx/ssl/inception.crt -keyout /etc/nginx/ssl/inception.key -subj "/C=FR/ST=IDF/L=Paris/O=42/OU=42/CN=ptme.com/UID=ptme"
RUN mkdir -p /var/www/PTME/
RUN mkdir -p /var/www/PTME/static/
RUN chmod 755 /var/www/PTME/
RUN chown -R www-data:www-data /var/www/PTME/
RUN echo "Heyyy\n" > /var/www/PTME/static/text.txt
COPY conf/nginx.conf /etc/nginx/nginx.conf COPY conf/nginx.conf /etc/nginx/nginx.conf

View File

@ -20,10 +20,10 @@ http {
ssl_certificate /etc/nginx/ssl/inception.crt; ssl_certificate /etc/nginx/ssl/inception.crt;
ssl_certificate_key /etc/nginx/ssl/inception.key; ssl_certificate_key /etc/nginx/ssl/inception.key;
root /var/www/PTME/; root /var/www/djangoserver/;
location /static/ { location /static/ {
alias /var/www/PTME/; alias /var/www/djangoserver/static/;
} }
location / { location / {