Kadonneen Gambitin Metsästys nettipeli titeenit tapahtumaan.
Authors: Tijam Moradi @tikimo & Hugo Hutri @hugohutri
docker-compose -f compose-tijam-dockerhub.yaml buildThis way you get two images:
tijam/kgm:frontas frontendtijam/kgm:backas backend
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tijam/kgm back 32b35d99d65a 2 minutes ago 297MB
tijam/kgm front e421c45f17d1 16 minutes ago 42.2MBNow run locally or push to dockerhub.
Attach host:4200 to container:80 by running:
docker run --name kgm-frontend -d -it -p 127.0.0.1:4200:80/tcp tijam/kgm:frontAttach host:3086 to container:3086 by running:
docker run --name kgm-backend -d -it -p 127.0.0.1:3086:3086/tcp tijam/kgm:backLogin to Docker Hub with docker login
First make sure you have used docker-compose's build command (found earlier in this md).
Push using:
docker-compose -f compose-tijam-dockerhub.yaml pushPull front and backend on separate commands:
sudo docker pull tijam/kgm:back sudo docker pull tijam/kgm:front Get container id with docker ps.
Stop containers
docker stop <backend id> <frontend id>Remove containers
docker rm <backend id> <frontend id>Attach host:4200 to container:80 by running:
sudo docker run -d -it -p 127.0.0.1:4200:80/tcp tijam/kgm:frontAttach host:3086 to container:3086 by running:
sudo docker run -d -it -p 127.0.0.1:3086:3086/tcp tijam/kgm:backVerify that everything is running with:
sudo docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2e1d013ab47c tijam/kgm:back "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 127.0.0.1:3086->3086/tcp kgm-backend
185a4c2ae210 tijam/kgm:front "/docker-entrypoint.…" 9 seconds ago Up 8 seconds 127.0.0.1:4200->80/tcp kgm-frontendNote: this sample setup is on a host machine that already has Nginx that routes multipel other applications. In this case, the KGM frontend and backend containers are not the only stuff running on the host. The KGM frontend container already ahs its own Nginx, so use that as standalone if possible. Note2: After putting
Put following nginx conf files in /etc/nginx/sites-available Then create symbolic link to /etc/nginx/sites-enabled with:
sudo ln -s /etc/nginx/sites-available/api.ikuinenheinakuu.fi.conf /etc/nginx/sites-enabled/api.ikuinenhe inakuu.fi.confExpected result:
tijam@ubuntu-8gb-hel1-2:/etc/nginx/sites-available$ ll ../sites-enabled/
total 8.0K
drwxr-xr-x 2 root root 4.0K Jan 11 12:24 ./
drwxr-xr-x 8 root root 4.0K Jan 11 12:25 ../
lrwxrwxrwx 1 root root 54 Jan 11 12:24 api.ikuinenheinakuu.fi.conf -> /etc/nginx/sites-available/api.ikuinenheinakuu.fi.conf
lrwxrwxrwx 1 root root 50 Jul 15 11:50 ikuinenheinakuu.fi.conf -> /etc/nginx/sites-available/ikuinenheinakuu.fi.conf server {
server_name api.ikuinenheinakuu.fi;
root /var/www/ikuinenheinakuu.fi;
location / {
proxy_pass http://localhost:3086;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ikuinenheinakuu.fi/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ikuinenheinakuu.fi/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = api.ikuinenheinakuu.fi) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name api.ikuinenheinakuu.fi;
return 404; # managed by Certbot
} server {
server_name ikuinenheinakuu.fi www.ikuinenheinakuu.fi;
root /var/www/ikuinenheinakuu.fi;
location / {
proxy_pass http://localhost:4200;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ikuinenheinakuu.fi/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ikuinenheinakuu.fi/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.ikuinenheinakuu.fi) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = ikuinenheinakuu.fi) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name ikuinenheinakuu.fi www.ikuinenheinakuu.fi;
return 404; # managed by Certbot
}Test and validate the configuration with
sudo nginx -tTo get SSL, expand the server cert with
sudo certbot --nginxValidate nginx again:
sudo nginx -tsudo service nginx restartNavigate to url (ikuinenheinakuu.fi etc) and see result. If not visible, make sure docker containers are running. You can use cURL command on the host to see if it works within the machine:
curl localhost:3086