Configure docker for local environment #9

Merged
Sieciech merged 2 commits from 7-docker into dev 2021-07-23 16:10:36 +00:00
15 changed files with 167 additions and 1 deletions
Showing only changes of commit 4f72c5b135 - Show all commits

4
docker/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
logs/*
!logs/.gitkeep
cache/*/*
!cache/*/.gitkeep

49
docker/Dockerfile Normal file
View File

@ -0,0 +1,49 @@
FROM debian:10
RUN apt update \
&& echo "Binary::apt::APT::Keep-Downloaded-Packages \"true\";" | tee /etc/apt/apt.conf.d/01keep-debs \
&& apt install -y wget lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 gcc g++ make \
&& echo "configure repos" \
&& echo "deb https://packages.sury.org/php/ buster main" | tee /etc/apt/sources.list.d/php.list \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/postgresql.list \
&& echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/buster pgadmin4 main" | tee /etc/apt/sources.list.d/pgdg.list \
&& echo "download keys" \
&& (wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add - ) \
&& (wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - ) \
&& (wget -qO - https://www.pgadmin.org/static/packages_pgadmin_org.pub | apt-key add - ) \
&& echo "install nodejs" \
&& wget -qO - https://deb.nodesource.com/setup_16.x | bash - \
&& echo "update repos" \
&& apt update \
&& echo "install software" \
&& apt install -y aptitude nano openssh-server unzip \
&& apt install -y postgresql pgadmin4 \
&& apt install -y php8.0 php8.0-ctype php8.0-iconv php8.0-simplexml php8.0-tokenizer php8.0-fpm php8.0-pdo php8.0-pdo-pgsql php8.0-pgsql php8.0-mbstring php8.0-zip \
&& apt install -y nginx \
&& apt install -y nodejs \
&& echo "configure tools" \
&& echo "# angular" \
&& npm install -g @angular/cli \
&& echo "# composer" \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php --install-dir=/usr/local/bin/ --filename=composer \
&& php -r "unlink('composer-setup.php');" \
&& echo "# nginx" \
&& ln -s /web/config/nginx/app.conf /etc/nginx/conf.d/app.conf \
&& ln -s /web/config/nginx/php80.conf /etc/nginx/php80.conf \
&& echo "# postgresql" \
&& echo "postgres:WeryStronkPaz2" | chpasswd \
&& echo "# pgadmin4" \
&& bash -c 'PGADMIN_SETUP_EMAIL="michal@fufle.net" PGADMIN_SETUP_PASSWORD="password" /usr/pgadmin4/bin/setup-web.sh --yes' \
&& echo "" > /etc/nginx/sites-enabled/default \
&& echo "!!! DONE !!!"
VOLUME /web/backend/vendor
VOLUME /web/backend/var
VOLUME /web/frontend/node_modules
EXPOSE 7700
STOPSIGNAL SIGQUIT
CMD ["bash", "/web/config/startup.sh"]

0
docker/cache/.gitkeep vendored Normal file
View File

0
docker/cache/apt/.gitkeep vendored Normal file
View File

0
docker/cache/postgres/.gitkeep vendored Normal file
View File

20
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
version: "3.9"
services:
cureapp:
build: .
ports:
- target: 7700
published: 7700
volumes:
- .:/web/config
- ../src/backend:/web/backend:cached
- ../src/frontend:/web/frontend:cached
- ./logs:/var/log
- vendor:/web/backend/vendor
- var:/web/backend/var
- nodemodules:/web/frontend/node_modules
volumes:
nodemodules:
vendor:
var:
nodemodules:

0
docker/logs/.gitkeep Normal file
View File

27
docker/nginx/app.conf Normal file
View File

@ -0,0 +1,27 @@
server {
server_name localhost;
listen 7700;
root /web/backend/public;
index index.htm index.html index.php;
location / {
proxy_bind 127.0.0.1;
proxy_pass http://localhost:4200;
}
location /api/ {
try_files $uri $uri/ /index.php/$uri?$query_string;
}
location /coverage/ {
alias /web/coverage/html-coverage/;
index index.html;
}
location /pgadmin4/ {
include proxy_params;
proxy_bind 127.0.0.1;
proxy_pass http://localhost:80;
proxy_set_header X-Script-Name /pgadmin4;
}
proxy_intercept_errors on;
fastcgi_intercept_errors on;
fastcgi_hide_header X-Powered-By;
include "php80.conf";
}

14
docker/nginx/php80.conf Normal file
View File

@ -0,0 +1,14 @@
index index.php index.html index.htm;
include snippets/fastcgi-php.conf;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffering off;
}

View File

@ -0,0 +1,4 @@
ALTER USER postgres WITH PASSWORD 'WeryStronkPaz2';
CREATE USER curenet WITH PASSWORD 'WeryStronkPaz2';
CREATE DATABASE curenet;
GRANT ALL PRIVILEGES ON DATABASE curenet to curenet;

39
docker/startup.sh Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
echo Configure logs
mkdir -p /var/log/{apache2,nginx,pgadmin,postgresql}
chmod root:postgres /var/log/postgresql -R
echo Configure volumes
[ -e /web/frontend/node_modules ] || ln -s /web/node /web/frontend/node_modules
[ -e /web/backend/var ] || ln -s /web/var /web/backend/var
[ -e /web/backend/vendor ] || ln -s /web/vendor /web/backend/vendor
echo Starting php-fpm server
service php8.0-fpm start
echo Starting nginx server
service nginx start
echo Starting apache2 server for pgAdmin4
service apache2 start
echo Starting postgresql database
service postgresql start
echo Starting ssh server
service ssh start
echo Configure database
su postgres -c psql postgres < /web/config/postgres/init-data.sql
echo Configure symfony
cd /web/backend
composer install
echo Configure angular
cd /web/frontend
npm i
echo Starting angular
ng serve

3
src/backend/.env.beta Normal file
View File

@ -0,0 +1,3 @@
APP_ENV=dev
APP_SECRET=0fc8d6b67b9f1100b3eb3e3c80d36fda
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"

3
src/backend/.env.dev Normal file
View File

@ -0,0 +1,3 @@
APP_ENV=dev
APP_SECRET=0fc8d6b67b9f1100b3eb3e3c80d36fda
DATABASE_URL="postgresql://curenet:WeryStronkPaz2@127.0.0.1:5432/curenet?serverVersion=13&charset=utf8"

3
src/backend/.env.prod Normal file
View File

@ -0,0 +1,3 @@
APP_ENV=dev
APP_SECRET=0fc8d6b67b9f1100b3eb3e3c80d36fda
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"

View File

@ -38,7 +38,7 @@
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "dist/frontend", "outputPath": "dist",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",