4 Commits

Author SHA1 Message Date
Alexis Leboeuf
8c49e7b6ee Adding a first version of a CI script 2026-02-16 12:23:19 +01:00
Alexis Leboeuf
f34f5719fd Merge remote-tracking branch 'refs/remotes/origin/Etape1' into Etape1 2026-02-12 12:44:16 +01:00
Alexis Leboeuf
3684a3513d First version of the CI, idk how to test it 2026-02-12 12:44:05 +01:00
trochas
bfc2253a27 front marche sur localhost/ 2026-02-12 12:24:46 +01:00
7 changed files with 102 additions and 110 deletions

View File

@@ -9,7 +9,6 @@ services:
- db
- etherpad
- back
- front
networks:
- app-network
@@ -17,16 +16,10 @@ services:
build:
context: ..
dockerfile: dockerfiles/front/Dockerfile
ports:
- "5000:5000"
- "5080:80"
volumes:
- ../doodlestudent/front:/app
environment:
- FLASK_ENV=development
depends_on:
- back
networks:
- app-network
@@ -43,8 +36,6 @@ services:
depends_on:
db:
condition: service_healthy
etherpad:
condition: service_healthy
networks:
- app-network
restart:
@@ -66,22 +57,14 @@ services:
retries: 5
networks:
- app-network
etherpad:
image: etherpad/etherpad:1.9.7
image: etherpad/etherpad
ports:
- "9001:9001"
volumes:
- ../doodlestudent/api/APIKEY.txt:/opt/etherpad-lite/APIKEY.txt
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "node -e \"require('http').get('http://127.0.0.1:9001', res => { process.exit(res.statusCode===200?0:1) }).on('error', ()=>process.exit(1))\""]
interval: 30s
timeout: 10s
start_period: 15s
retries: 5
mail:
image: bytemark/smtp
restart: always
@@ -90,7 +73,7 @@ services:
networks:
- app-network
networks: # Declare the network to be used by the services
app-network: # Is a user-defined network
#external: false # If true, Docker Compose will look for an existing network with the same name and use it. If false or not specified, Docker Compose will create a new network.
name: app-network #Name of the network (optional, Docker Compose will generate one if not provided)
networks:
app-network:
#external: false
name: app-network

View File

@@ -29,12 +29,10 @@ RUN chown 1001 /work \
EXPOSE 8080
USER 1001
#ENV quarkus_datasource_jdbc_url "jdbc:mysql://db:3306/tlc?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&createDatabaseIfNotExist=true&serverTimezone=Europe/Paris"
ENV quarkus_datasource_jdbc_url "jdbc:mysql://db:3306/tlc?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&createDatabaseIfNotExist=true&serverTimezone=Europe/Paris"
ENV quarkus_datasource_username tlc
ENV quarkus_datasource_password tlc
ENV QUARKUS_HIBERNATE_ORM_DATABASE_GENERATION update
ENV doodle_internalPadUrl "http://etherpad:9001/"
ENV doodle_externalPadUrl "http://etherpad:9001/"
ENV mailer_host mail
ENV mailer_port 25
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

View File

@@ -13,7 +13,6 @@ RUN npx ng build
FROM nginx:alpine
COPY --from=build /app/dist/tlcfront /usr/share/nginx/html
COPY nginxFront.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

View File

@@ -0,0 +1,26 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
##########################
# Proxy API requests to the back service
##########################
location /api/ {
proxy_pass http://back:8080/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
}
##########################
# FrontEnd returns
##########################
location / {
try_files $uri $uri/ /index.html;
}
}

52
gitlab-ci.yml Normal file
View File

@@ -0,0 +1,52 @@
stages:
- check
- build
- deploy
variables:
APP_REPO: "https://github.com/barais/doodlestudent.git"
SUBMODULE_PATH: "doodlestudent"
check_app_update:
stage: check
image: alpine:latest
before_script:
- apk add --no-cache git
script:
# Récupère le dernier commit distant
- LATEST_REMOTE=$(git ls-remote $APP_REPO HEAD | awk '{print $1}')
# Récupère le commit actuel du submodule
- CURRENT_SUBMODULE=$(git rev-parse HEAD:$SUBMODULE_PATH || echo "none")
- echo "Remote: $LATEST_REMOTE"
- echo "Current: $CURRENT_SUBMODULE"
# Compare
- |
if [ "$LATEST_REMOTE" != "$CURRENT_SUBMODULE" ]; then
echo "NEW_COMMIT=true" >> variables.env
else
echo "NEW_COMMIT=false" >> variables.env
fi
artifacts:
reports:
dotenv: variables.env
build_image:
stage: build
image: docker:latest
services:
- docker:dind
rules:
- if: '$NEW_COMMIT == "true"'
script:
- git submodule update --init --remote
- docker build -t myapp:latest .
- docker push myapp:latest
deploy:
stage: deploy
rules:
- if: '$NEW_COMMIT == "true"'
script:
- echo "Deploying..."
- docker compose up -f dockercompose/docker-compose.yml -d

View File

@@ -1,30 +1,9 @@
upstream front{
server front:5000;
}
upstream back{
server back:8080;
}
upstream etherpad{
server etherpad:9001;
}
upstream db{
server db:3306;
}
upstream smtp{
server smtp:25;
}
##########################
## FRONTEND + API
##########################
server {
listen 80;
listen [::]:80;
listen 443 ssl;
server_name _;
ssl_certificate /etc/letsencrypt/live/tondomaine.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tondomaine.com/privkey.pem;
root /usr/share/nginx/html;
index index.html;
@@ -32,7 +11,16 @@ server {
# Proxy API requests to the back service
##########################
location /api/ {
proxy_pass http://back:8080;
proxy_pass http://back:8080/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
}
location /pad/ {
proxy_pass http://etherpad:9001/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -44,7 +32,7 @@ server {
# FrontEnd returns
##########################
location / {
proxy_pass http://front:5080;
proxy_pass http://front:80/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -52,43 +40,9 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
##
## BACKEND
##
},
server {
listen 80;
listen [::]:80;
server_name _;
location / {
proxy_pass http://back:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
}
##
## ETHERPAD
##
server {
listen 80;
listen [::]:80;
server_name _;
location / {
proxy_pass http://etherpad:9001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
server_name tondomaine.com;
return 301 https://$host$request_uri;
}

View File

@@ -1,20 +0,0 @@
server {
location /api/polls {
proxy_pass http://back:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html?$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}