0% found this document useful (0 votes)
36 views

Deployment - Doc - NewDocker

The document describes the process for deploying an ePay core application to Docker containers. It involves: 1. Creating Dockerfiles for the application and a reverse proxy Nginx container. 2. Generating SSL certificates and config files for Nginx. 3. Defining the services and their dependencies in a docker-compose.yml file. 4. Building and running the containers with docker-compose up -d, making the application available over HTTPS. The process produces Docker images that can be uploaded to Docker Hub for deployment elsewhere.

Uploaded by

r.narender9904
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Deployment - Doc - NewDocker

The document describes the process for deploying an ePay core application to Docker containers. It involves: 1. Creating Dockerfiles for the application and a reverse proxy Nginx container. 2. Generating SSL certificates and config files for Nginx. 3. Defining the services and their dependencies in a docker-compose.yml file. 4. Building and running the containers with docker-compose up -d, making the application available over HTTPS. The process produces Docker images that can be uploaded to Docker Hub for deployment elsewhere.

Uploaded by

r.narender9904
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ePay Core

Deployment Process

Date Version Author Notes


03-21-2023 1.0 Narender Ramadheni First draft

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. Docker Deployment Process


2.1.1. Overview
This section will outline how to deploy the ePay app in a Docker.

2.1.2. Prerequisites
Need to have Docker software installed on the machine.

2.1.3. Steps involved in docker container creation.


a. Create a docker file with the following commands. - Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base


WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y libpng-dev libjpeg-dev curl libxi6 build-essential libgl1-mesa-glx
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get install -y nodejs

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build


WORKDIR /src
COPY ["src/WebAR.Service.API/WebAR.Service.API.csproj", "src/WebAR.Service.API/"]
COPY ["src/WebAR.Service.Services/WebAR.Service.Services.csproj", "src/WebAR.Service.Services/"]
RUN dotnet restore "src/WebAR.Service.API/WebAR.Service.API.csproj"
COPY . .
WORKDIR "/src/src/WebAR.Service.API"
RUN dotnet build "WebAR.Service.API.csproj" -c Release -o /app/build

FROM build AS publish


RUN dotnet publish "WebAR.Service.API.csproj" -c Release -o /app/publish

FROM base AS final


WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebAR.Service.API.dll"]

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

COPY nginx.conf /etc/nginx/nginx.conf

3. localhost.crt: certificate file


4. localhost.key: certificate key file.
5. nginx.conf
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
upstream web-api {
server api:5000;
}
server {
listen 80;
server_name localhost;

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.

2.1.4. Docker images upload and deploy.

Once we have the images, we can upload them to docker hub which can be pulled into any
system and deployed.

You might also like