BLogic Systems

Deployment

Last updated on 

Deploy Blogic Online Ordering project

Proxy

Repository

Clone the repository and checkout to staging branch

git clone https://github.com/BLOGICSYSTEMS/WebOrderOnlineProxy

Prepare

  • Edit appsettings.json
{
  "ConnectionStrings": {
    "RedisCache": "172.17.0.1:6379" // <-- Change this
  },
}
  • Edit Helpers\WEB_CONST.cs:
public class WEB_CONST
{
    public static string[] HOST = { "http://*:80" }; // <-- Change this
}
  • Auto build and deploy script deploy.sh:
#!/bin/bash

# Build docker image
REGISTRY='ghcr.io'
OWNER='blogic-datht'
IMAGE_NAME='online-ordering-proxy'

echo '🐳  Build docker image with tag latest'

# ghcr.io/blogic-datht/online-ordering-proxy
docker build -t "$REGISTRY/$OWNER/$IMAGE_NAME:latest" . || exit

echo '🚀  Build done!'
echo ''
echo '🌏  Publish image to Github registry'

USERNAME='blogic-datht'
CR_PAT='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'

# login to github registry
echo $CR_PAT | docker login ghcr.io -u $USERNAME --password-stdin

# push image to github registry
docker push $REGISTRY/$OWNER/$IMAGE_NAME:latest || exit

# Deploy

echo "🚀 Deploying via remote SSH"

SERVER_IP='192.168.0.194'
IMAGE_NAME='ghcr.io/blogic-datht/online-ordering-proxy'
CONTAINER_NAME='online-ordering-proxy'

ssh -i "~/.ssh/id_rsa" "bls@${SERVER_IP}" \
  "docker pull ${IMAGE_NAME} \
  && docker compose -f composes/${CONTAINER_NAME}/docker-compose.yaml down \
  && docker compose -f composes/${CONTAINER_NAME}/docker-compose.yaml up -d \
  && docker system prune -f"

echo "🎉 Successfully deployed, hooray!"
  • Create docker-compose.yml
version: "3.4"

services:
  redis:
    image: "redis"
    container_name: "redis"
    restart: "unless-stopped"
    ports:
      - "6379:6379"
    networks:
      - "online_ordering_network"

  proxy:
    image: "ghcr.io/blogic-datht/online-ordering-proxy"
    container_name: "online-ordering-proxy"
    restart: "unless-stopped"
    ports:
      - "6969:80"
    networks:
      - "online_ordering_network"

networks:
  online_ordering_network:
    external: true

Run

Create a docker network for this stack:

docker network create online_ordering_network

Run the following command to build docker image with tag latest and publish to GithubPackage

./publish.sh

or run docker compose up -d to test in your localhost