Skip to content
Snippets Groups Projects
Commit 5ba5bdd0 authored by Leonardo Alain Surdez's avatar Leonardo Alain Surdez
Browse files

Merge branch 'Docker' into 'master'

[Feat] Docker configuration

See merge request !6
parents f478e053 f12717ab
No related branches found
No related tags found
1 merge request!6[Feat] Docker configuration
FROM php:8.2-apache
RUN apt-get update; apt-get install -yq git vim zip;
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN export PATH=$PATH:/root/.composer/vendor/bin
RUN docker-php-ext-install pdo pdo_mysql
RUN a2enmod rewrite
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN echo "LimitRequestFieldSize 81920" > /etc/apache2/conf-enabled/say-yes-to-bearer-tokens.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# XDEBUG
RUN yes | pecl install xdebug
RUN docker-php-ext-enable xdebug
# Enable Remote xdebug
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "xdebug.log=/proc/self/fd/1" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/xdebug.ini
# https://github.com/docker/for-win/issues/12673 says host.docker.internal does not work (and we cannot trust the guessing mechanism, because
# we are going through Traefik):
RUN echo "xdebug.client_host=172.22.0.1" >> /usr/local/etc/php/conf.d/xdebug.ini
\ No newline at end of file
FROM php:8.2-apache
RUN apt-get update;
RUN apt-get install -f -y msmtp msmtp-mta;
RUN echo 'sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t"' >> /usr/local/etc/php/php.ini
RUN echo 'sendmail_from = "noreply@epfl.ch"' >> /usr/local/etc/php/php.ini
RUN touch /etc/msmtprc
RUN echo "defaults" > /etc/msmtprc
RUN echo "logfile /var/log/msmtp.log" >> /etc/msmtprc
RUN echo "" >> /etc/msmtprc
RUN echo "account epfl" >> /etc/msmtprc
RUN echo "host mail.epfl.ch" >> /etc/msmtprc
RUN echo "port 25" >> /etc/msmtprc
RUN echo "from noreply@epfl.ch" >> /etc/msmtprc
RUN echo "" >> /etc/msmtprc
RUN echo "account default : epfl" >> /etc/msmtprc
#php -r "mail('nicolas.borboen@epfl.ch', 'Test Postfix', 'Test mail from postfix');"
RUN docker-php-ext-install pdo_mysql
# cleanup
RUN apt-get -y autoremove && apt-get -y clean;
DC = docker compose -f ./docker-compose-dev.yml
up: network
$(DC) up -d
stop:
$(DC) down
start: up
$(DC) exec gest sh -c 'npm i --no-funding'
$(DC) exec api bash -c 'composer update && composer install'
build:
$(DC) build
list:
$(DC) ps
restart: stop up
network:
if [ -z "$$(docker network ls -q -f name=canap_network)" ]; then \
docker network create canap_network; \
fi
version: '3'
networks:
canap_network:
external: true
services:
# The DB of the application
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: canap_db
MYSQL_DATABASE: canap_db
MYSQL_USER: canap_db
MYSQL_PASSWORD: canap_db
volumes:
- ../data/DB/init-sql:/docker-entrypoint-initdb.d
- ../data/DB/canap_db:/var/lib/mysql
ports:
- "127.0.0.1:9906:3306"
expose:
- 9906
labels:
- "traefik.enable=false"
networks:
- canap_network
# The form for the applicants
form:
build:
context: ./
dockerfile: Dockerfile-form.dockerfile
depends_on:
- db
volumes:
- ../Formulaire:/var/www/html/
environment:
ENVIRONMENT: docker
FILESERVERPATH: '/var/www/html/data/candidatures/'
SENDEMAILS: true
MAIL_FROM: 'noreply+formulaireApprentis@epfl.ch'
MAIL_CONTACT: 'leonardo.surdez@epfl.ch'
MAIL_REPLYTO: 'leonardo.surdez@epfl.ch'
DB_CONNECTION: mysql
DB_HOST: db
DB_PORT: 3306
DB_DATABASE: canap_db
DB_USERNAME: canap_db
DB_PASSWORD: canap_db
labels:
- traefik.enable=true
- traefik.http.routers.form.rule=Host(`localhost`)
- traefik.http.routers.form.tls=true
- traefik.http.services.form.loadbalancer.server.port=80
networks:
- canap_network
# The API for the management app
api:
build:
context: ./
dockerfile: Dockerfile-api.dockerfile
volumes:
- ../API:/var/www/html/
environment:
DB_CONNECTION: mysql
DB_HOST: db # todo
DB_PORT: 3306 # todo
DB_DATABASE: canap_db # todo
DB_USERNAME: canap_db # todo
DB_PASSWORD: canap_db # todo
TEQUILA_RETURN_URL: 'https://localhost/gest/#/?key='
labels:
- traefik.enable=true
- traefik.http.routers.api.rule=Host(`localhost`) && PathPrefix(`/api`)
- traefik.http.routers.api.tls=true
- traefik.http.services.api.loadbalancer.server.port=80
networks:
- canap_network
# The management app
gest:
image: node:15-alpine
user: node
working_dir: /home/node/app
depends_on:
- api
environment:
API_LOCATION: "https://localhost/api"
LOGIN_REDIRECT: "https://localhost/api/auth/login"
NODE_ENV: dev
volumes:
- ../Gestion:/home/node/app
- ../Formulaire/data/candidatures:/var/www/html/data/candidatures/
entrypoint: /bin/sh
labels:
- traefik.enable=true
- traefik.http.routers.gest.rule=Host(`localhost`) && PathPrefix(`/gest`)
- traefik.http.routers.gest.tls=true
- traefik.http.services.gest.loadbalancer.server.port=8080
command:
- "-c"
- env DEBUG=express:router npm run serve-docker
networks:
- canap_network
traefik:
image: traefik:latest
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes: #monter le socket docker
- /var/run/docker.sock:/var/run/docker.sock
command:
- --api.insecure=true # active l'interface API de Traefik sans authentification
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --accesslog=true
- --log.level=DEBUG
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
networks:
- canap_network
#FROM php:7.3-stretch
FROM php:8.0-apache
FROM php:8.2-apache
RUN apt-get update; apt-get install -yq git vim zip;
WORKDIR /var/www/html/
RUN apt-get update; apt-get install -yq git vim zip libldap2-dev;
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN export PATH=$PATH:/root/.composer/vendor/bin
......@@ -11,21 +12,14 @@ RUN a2enmod rewrite
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# XDEBUG
RUN yes | pecl install xdebug
RUN docker-php-ext-enable xdebug
# Enable Remote xdebug
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "xdebug.default_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "xdebug.client_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "xdebug.discover_client_host=on" >> /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "LimitRequestFieldSize 81920" > /etc/apache2/conf-enabled/say-yes-to-bearer-tokens.conf
RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
docker-php-ext-install ldap
# RUN chmod 777 -R /var/www/html/storage
# Copy the code into the container
COPY ./API /var/www/html/
RUN composer update && composer install
# RUN apt-get install nodejs -y; apt-get install npm -y;
# RUN useradd -u 1000 containerUser
# RUN usermod -a -G root containerUser
\ No newline at end of file
# Change permissions on copied files
RUN chown -R www-data:www-data /var/www/html/
# USER www-data
FROM php:8.0-apache
FROM php:8.2-apache
RUN apt-get update;
RUN apt-get install -f -y msmtp msmtp-mta;
......@@ -16,12 +16,15 @@ RUN echo "from noreply@epfl.ch" >> /etc/msmtprc
RUN echo "" >> /etc/msmtprc
RUN echo "account default : epfl" >> /etc/msmtprc
#php -r "mail('nicolas.borboen@epfl.ch', 'Test Postfix', 'Test mail from postfix');"
RUN docker-php-ext-install pdo_mysql
# cleanup
RUN apt-get -y autoremove && apt-get -y clean;
# Copy the config into the container
COPY ./Docker/canap_apache.conf /etc/apache2/conf-enabled
# Copy the code into the container
COPY ./form /var/www/html/
FROM node:15-alpine as build
WORKDIR /home/node/app
COPY ./gest /home/node/app
RUN npm install -y && npm run build
FROM httpd:latest
WORKDIR /root/
COPY --from=build /home/node/app/dist /usr/local/apache2/htdocs/gest
COPY Docker/docker-entrypoint-gest.sh /docker-entrypoint.sh
CMD /docker-entrypoint.sh
\ No newline at end of file
PassEnv DB_HOST DB_NAME DB_USER DB_PASSWORD
PassEnv SENDEMAILS MAIL_FROM MAIL_CONTACT MAIL_REPLYTO
PassEnv ENVIRONMENT
PassEnv FILESERVERPATH
\ No newline at end of file
version: '3'
services:
# The DB of the application
db:
image: mysql:5.7
container_name: canap_db
environment:
MYSQL_ROOT_PASSWORD: canap_db
MYSQL_DATABASE: canap_db
MYSQL_USER: canap_db
MYSQL_PASSWORD: canap_db
#command: mysqld --general-log=1 --general-log-file=/var/log/mysql/general-log.log
volumes:
- ../data/DB/init-sql:/docker-entrypoint-initdb.d
- ../data/DB/canap_db:/var/lib/mysql
ports:
- "9906:3306"
expose:
- 9906
# The form for the applicants
form:
build:
context: ./
dockerfile: Dockerfile-form.dockerfile
container_name: canap_form
depends_on:
- db
volumes:
- ../Formulaire:/var/www/html/
- ../data/candidatures:/var/www/html/data/candidatures/
ports:
- "8180:80"
# The API for the management app
api:
build:
context: ./
dockerfile: Dockerfile-api.dockerfile
container_name: canap_api
volumes:
- ../API:/var/www/html/
ports:
- "8181:80"
# The management app
gest:
image: node:15-alpine
container_name: canap_gest
user: node
working_dir: /home/node/app
depends_on:
- api
environment:
- NODE_ENV=development #production
volumes:
- ../Gestion:/home/node/app
ports:
- "8080:8080"
entrypoint: /bin/sh
command:
- "-c"
- npm i && npm run serve-docker
# networks:
# default:
# external:
# name: canap_network
version: '3'
services:
db:
image: mysql:5.7
container_name: canap_db
environment:
MYSQL_ROOT_PASSWORD: canap_db
MYSQL_DATABASE: canap_db
MYSQL_USER: canap_db
MYSQL_PASSWORD: canap_db
volumes:
- ./DB/SQL:/docker-entrypoint-initdb.d
- ./DB/data:/var/lib/mysql
ports:
- "9906:3306"
expose:
- 9906
form:
build:
context: ./
dockerfile: Dockerfile-form.dockerfile
container_name: canap_form
depends_on:
- db
volumes:
- .:/var/www/html/
ports:
- "8180:80"
networks:
default:
external:
name: canap_network
version: '3'
services:
api:
build:
context: ./
dockerfile: Dockerfile-api.dockerfile
container_name: canap_api
volumes:
- ./API:/var/www/html/
ports:
- "8181:80"
gest:
image: node:15-alpine
container_name: canap_gest
user: node
working_dir: /home/node/app
depends_on:
- api
environment:
- NODE_ENV=development #production
volumes:
- ./Site:/home/node/app
ports:
- "8080:8080"
entrypoint: /bin/sh
command:
- "-c"
- npm i && npm run serve-docker
networks:
default:
external:
name: canap_network
\ No newline at end of file
#!/bin/sh
set -e -x
# Substitute 12-factored env vars now (we couldn't do that at compile time
# because we don't know the values until runtime).
# sed -i -e "s|_REPLACE_ME_LATER__API_LOCATION|$API_LOCATION|" \
# -e "s|_REPLACE_ME_LATER__LOGIN_REDIRECT|$LOGIN_REDIRECT|" \
# /usr/local/apache2/htdocs/gest/js/app.*.js
exec /usr/local/bin/httpd-foreground
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment