Deployment
π Anything to know to deploy Sensa Booking project with Docker π π³

Prepare
- Github personal access token, with pull repo permission
Personal access token are an alternative to using passwords for authentication to GitHub, see βCreating a personal access token.β
username=<gh_username>
token=<gh_pull_token>- Github personal access token, with push & pull package permission
GitHub Packages only supports authentication using a personal access token (classic). For more information, see βCreating a personal access token.β
registry_token=<gh_package_token>Booking api
- Clone project
git clone https://username:[email protected]/BLOGICSYSTEMS/BLogicBookingOnlineApi- Build docker and push docker image to Github Packages
Generate your github package token, open file /scripts/publish.sh, replace <gh_package_token> with your token, then:
cd BLogicBookingOnline.API
./publish.shThis script is programmed to build asp.net, containerize it, and push to Github Packages
Booking dashboard
- Clone project
git clone https://username:[email protected]/BLOGICSYSTEMS/BlogicBookingOnlineDasboard- Build docker and push docker image to Github Packages
Generate your github package token, open file /scripts/publish.sh, replace <gh_package_token> with your token, then:
npm run publishThis command actually run bash script located at /scripts/publish.sh
This script is programmed to build angular app, containerize it, and push to Github Packages
Booking page
- Clone project
git clone https://username:[email protected]/BLOGICSYSTEMS/BLogicBookingOnline- Build docker and push docker image to Github Packages
Generate your github package token, open file /scripts/publish.sh, replace <gh_package_token> with your token, then:
npm run publishThis command actually run bash script located at /scripts/publish.sh
This script is programmed to build angular app, containerize it, and push to Github Packages
Booking admin management
- Clone project
git clone https://username:[email protected]/BLOGICSYSTEMS/BLogicBookingOnline- Build docker and push docker image to Github Packages
Generate your github package token, open file /scripts/publish.sh, replace <gh_package_token> with your token, then:
npm run publishThis command actually run bash script located at /scripts/publish.sh
This script is programmed to build angular app, containerize it, and push to Github Packages
Booking check-in
- Clone project
git clone https://username:[email protected]/BLOGICSYSTEMS/BLogicBookingCheckInApp- Build docker and push docker image to Github Packages
Generate your github package token, open file /scripts/publish.sh, replace <gh_package_token> with your token, then:
npm run publishThis command actually run bash script located at /scripts/publish.sh
This script is programmed to build angular app, containerize it, and push to Github Packages
Booking wiki
- Clone project
git clone https://username:[email protected]/BLOGICSYSTEMS/BLogicBookingWiki- Build docker and push docker image to Github Packages
Generate your github package token, open file /scripts/publish.sh, replace <gh_package_token> with your token, then:
npm run publishThis command actually run bash script located at /scripts/publish.sh
This script is programmed to build astro app, containerize it, and push to Github Packages
Install Docker environment
- π₯οΈ Remote to deploy server. Via Remote Desktop, Any Desk, SSH, etc.
- π³ Install Docker Engine
By taking advantage of Dockerβs methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.
- π₯ Install Portainer
The most popular docker container management platform in the world.
Open terminal on remote server, run:
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latestNow that the installation is complete, you can log into your Portainer Server instance by opening a web browser and going to:
https://localhost:9443Replace localhost with the relevant IP address or FQDN if needed. Then, register an admin account:
user_name: admin
password: X9mtZmWa8gph+7+g- Setup Portainer environment
- From Portainer Dashboard, click Environment > Add environment
- Choose Docker Swarm > Start Wizard
- Choose Socket, enter
booking-prodfor name input - Click Connect
- Add Github Packages to Portainer registries
- From Portainer Dashboard > Registries > Add registry
- Registry provider: select Custom registry
- Name: GithubPackages
- Registry URL: ghcr.io
- Enable Authentication
- User name:
- Password:
- Create docker network for api and database containers
docker network create booking_networkDeploy via Portainer Dashboard
From booking-prod environment, open Stacks management, click Add stack
There are 5 stack need to run:
| Database | ms sql server 2022 |
| Booking Api | asp.net 7 |
| Booking Dashboard | angular |
| Booking Page | angular |
| Booking Admin | angular |
| Booking Checkin | angular |
| Booking Wiki | astro.build |
| Traefik | reverse proxy |
- Deploy database stack:
Stack name: booking-database
version: "3.4"
services:
mssql:
image: "mcr.microsoft.com/mssql/server:2022-latest"
container_name: "booking-database"
user: "root"
ports:
- "1433:1433"
environment:
SA_PASSWORD: "S3cur3P@ssW0rd!"
ACCEPT_EULA: "Y"
networks:
- "booking_network"
volumes:
- "sqldata:/var/opt/mssql"
restart: "unless-stopped"
networks:
booking_network:
external: true
volumes:
sqldata:- Deploy booking api stack:
Stack name: booking-api
version: "3.4"
services:
booking-api:
image: "ghcr.io/blogic-datht/booking-api"
container_name: "booking-api"
ports:
- "5111:443"
- "5110:80"
volumes:
- "booking_api_log_data:/app/Logs"
- "booking_api_resources_data:/app/Resources"
networks:
- "booking_network"
restart: "unless-stopped"
labels:
- "traefik.port=9624"
- "traefik.http.routers.booking-api.rule=Host(`api.staging.sensabooking.com`)"
- "traefik.http.routers.booking-api.tls=true"
networks:
booking_network:
external: true
volumes:
booking_api_log_data:
booking_api_resources_data:- Deploy booking dashboard stack
Stack name: booking-dashboard
version: "3.4"
services:
booking-dashboard:
image: "ghcr.io/blogic-datht/booking-dashboard"
container_name: "booking-dashboard"
ports:
- "9622:80"
restart: "unless-stopped"
networks:
- "booking_network"
labels:
- "traefik.port=9622"
- "traefik.http.routers.booking-dashboard.rule=Host(`go.staging.sensabooking.com`)"
- "traefik.http.routers.booking-dashboard.tls=true"
networks:
booking_network:
external: true- Deploy booking page stack
Stack name: booking-page
version: "3.4"
services:
booking-page:
image: "ghcr.io/blogic-datht/booking-page"
container_name: "booking-page"
ports:
- "9623:80"
restart: "unless-stopped"
networks:
- "booking_network"
labels:
- "traefik.port=9623"
- "traefik.http.routers.booking-page.rule=Host(`staging.sensabooking.com`)"
- "traefik.http.routers.booking-page.tls=true"
networks:
booking_network:
external: true- Deploy booking admin management stack
Stack name: booking-management
version: "3.4"
services:
booking-management:
image: "ghcr.io/blogic-datht/booking-management"
container_name: "booking-management"
ports:
- "9624:80"
restart: "unless-stopped"
networks:
- "booking_network"
labels:
- "traefik.port=9624"
- "traefik.http.routers.booking-management.rule=Host(`admin.staging.sensabooking.com`)"
- "traefik.http.routers.booking-management.tls=true"
networks:
booking_network:
external: true- Deploy booking check-in stack
Stack name: booking-checkin
version: "3.4"
services:
booking-checkin:
image: "ghcr.io/blogic-datht/booking-checkin"
container_name: "booking-checkin"
ports:
- "9626:80"
restart: "unless-stopped"
labels:
- "traefik.port=9626"
- "traefik.http.routers.booking-page.rule=Host(`booking-checkin.blogicsystems.com`)"
- "traefik.http.routers.booking-page.tls=true"
networks:
booking_network:
external: true- Deploy booking wiki stack
Stack name: booking-wiki
version: "3.4"
services:
dashboard:
image: "ghcr.io/blogic-datht/booking-wiki"
container_name: "booking-wiki"
ports:
- "9625:80"
restart: "unless-stopped"
networks:
- "booking_network"
labels:
- "traefik.port=9625"
- "traefik.http.routers.booking-wiki.rule=Host(`wiki.staging.sensabooking.com`)"
- "traefik.http.routers.booking-wiki.tls=true"
networks:
booking_network:
external: true- (Optional) Deploy reverse proxy stack with Traefik
- Create a file at
C:\traefik\certificateswith namecertificates.yaml;
- Create a file at
tls:
certificates:
# first certificate
- certFile: /wiki.sensabooking/cert.cert
keyFile: /wiki.sensabooking/cert.key
# second certificate
- certFile: /api.sensabooking/cert.cert
keyFile: /api.sensabooking/cert.key
stores:
default:
defaultCertificate:
certFile: /wiki.sensabooking/cert.cert
keyFile: /wiki.sensabooking/cert.key- Copy certificate files to
C:\traefik\certificatesfolder (if existed) - Deploy Traefik
Stack name: traefik
version: "3.4"
services:
traefik:
image: "traefik:v2.9"
container_name: "traefik"
command:
- "--entrypoints.web.address=:80"
- "--entrypoints.web-secure.address=:443"
- "--providers.docker=true"
- "--api.insecure"
- "--providers.file.directory=/certificates/"
- "--providers.file.watch=true"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "C:\\traefik\\certificates\\:/certificates/"
networks:
- "booking_network"
restart: "unless-stopped"
networks:
booking_network:
external: trueRestore database
- Create backup folder in docker container
docker exec -it booking-database mkdir /var/opt/mssql/backup- Name the backup file as
booking.bakthen copy it to docker container
docker cp booking.bak booking-database:/var/opt/mssql/backup- List out logical file names and paths inside the backup
with docker command
docker exec -it booking-database /opt/mssql-tools/bin/sqlcmd -S localhost \
-U SA -P 'S3cur3P@ssW0rd!' \
-Q 'RESTORE FILELISTONLY FROM DISK = "/var/opt/mssql/backup/booking.bak"' \
| tr -s ' ' | cut -d ' ' -f 1-2or with sql query
RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/booking.bak'- Restore database. Specify new paths for each of the files in the previous step
with docker command
docker exec -it booking-database /opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P 'S3cur3P@ssW0rd!' \
-Q 'RESTORE DATABASE BLOGICPOS9 FROM DISK = "/var/opt/mssql/backup/booking.bak" WITH MOVE "BLOGICPOS9" TO "/var/opt/mssql/data/BLOGICPOS9.mdf", MOVE "BLOGICPOS9_log" TO "/var/opt/mssql/data/BLOGICPOS9_log.ldf"'or with sql query
RESTORE DATABASE BLOGICPOS9 FROM DISK = '/var/opt/mssql/backup/booking.bak' WITH
MOVE 'BLOGICPOS9' TO '/var/opt/mssql/data/BLOGICPOS9.mdf',
MOVE 'BLOGICPOS9_log' TO '/var/opt/mssql/data/BLOGICPOS9_log.ldf'Restore Resources Folder
Unzip Resources.zip then run the following command:
docker cp Resources/. booking-api:/app/Resources/Done π
Booking dashboard is running at
http://localhost:9622Booking page is running at
http://localhost:9623Booking api is running at
http://localhost:5110Booking admin management is running at
http://localhost:9624Booking check-in is running at
http://localhost:9626Booking wiki is running at
http://localhost:9625Sentry
[email protected]
Blogicsentry