Deployment - Doc - NewDocker
Deployment - Doc - NewDocker
Deployment Process
Contents
1. Overview.............................................................................................................................................2
2. Docker Deployment Process................................................................................................................2
2.1.1. Overview..............................................................................................................................2
2.1.2. Prerequisites........................................................................................................................2
2.1.3. Steps involved in docker container creation........................................................................2
2.1.4. Docker images upload and deploy.......................................................................................5
1. Overview
This document will be describing the process of deploying the ePay core builds to Docker.
2.1.2. Prerequisites
Need to have Docker software installed on the machine.
The above docker file will create container but it will run on http server, to run on https we need
to create a reverse proxy by using nginx server. Then we will have to create to images one for
ePay and another for reverse proxy nginx and to combine these to we will be creating a docker
compose file which will create two images
b. Creating a docker-compose.yml file
version: "3.7"
services:
reverseproxy:
build:
context: ./Nginx
dockerfile: Nginx.Dockerfile
ports:
- "80:80"
- "443:443"
restart: always
api:
depends_on:
- reverseproxy
build:
context: ./
dockerfile: Dockerfile
expose:
- "5000"
restart: always
We have to create a folder with the name: Nginx with the following file in it.
1. localhost.conf:
[req]
default_bits = 2048
default_keyfile = localhost.key
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_ca
[req_distinguished_name]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Texas
localityName = Locality Name (eg, city)
localityName_default = Dallas
organizationName = Organization Name (eg, company)
organizationName_default = localhost
organizationalUnitName = organizationalunit
organizationalUnitName_default = Development
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = localhost
commonName_max = 64
[req_ext]
subjectAltName = @alt_names
[v3_ca]
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = 127.0.0.1
2. Nginx.Dockerfile
FROM nginx:latest
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/ssl/certs/localhost.crt;
ssl_certificate_key /etc/ssl/private/localhost.key;
location / {
proxy_pass http://web-api;
proxy_redirect off;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
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 X-Forwarded-Host $server_name;
}
}
}
6. Nginx-no-ssl.conf
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
upstream web-api {
server api:5000;
}
server {
listen 80;
server_name $hostname;
location / {
proxy_pass http://web-api;
proxy_redirect off;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
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 X-Forwarded-Host $server_name;
}
}
}
Once we have all the dependent files for Docker, we need to run the following commands
to generate docker image files.
1.docker-compose build
2.docker-compose up -d
Once the image is up a container is running then we can see the web site running on
https://epay.dev.com/
One thing to note here is that we have used a local certificate and used port 5000 in the
docker files which can be modified as per the requirements.
Once we have the images, we can upload them to docker hub which can be pulled into any
system and deployed.