Skip to content

Update Dockerfile

Update Dockerfile #36

name: Build and Deploy
on:
push:
branches:
- "elixir"
paths:
- "backend/**"
- "!README.md"
env:
SNAME1: rtc1
VIRTUAL_HOST1: rtc1.free4.chat
EXTERNAL_IP1: 54.238.1.42
PRIVATE_IP1: 172.26.8.68
SNAME2: rtc2
VIRTUAL_HOST2: rtc2.free4.chat
EXTERNAL_IP2: 18.182.39.157
PRIVATE_IP2: 172.26.25.248
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
TAG: prod
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Declare variables
id: vars
shell: bash
run: |
echo "::set-output name=version::$(git rev-parse --short HEAD)"
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build and push prod version
id: docker_build_prod
uses: docker/build-push-action@v3
with:
context: ./backend/
file: ./backend/Dockerfile
push: true
build-args: |
DASHBOARD_AUTH_USERNAME=${{ secrets.DASHBOARD_AUTH_USERNAME }}
DASHBOARD_AUTH_PASSWORD=${{ secrets.DASHBOARD_AUTH_PASSWORD }}
tags: madawei2699/free4chat:${{ env.TAG }}
deploy-rtc1:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Prepare .env file for the deployment
id: variables_population
run: printf "INTEGRATED_TURN_IP=$EXTERNAL_IP1 \nRELEASE_DISTRIBUTION=name \nRELEASE_NODE=$SNAME1@$PRIVATE_IP1 \nSECRET_KEY_BASE=$SECRET_KEY_BASE \nVIRTUAL_HOST=$VIRTUAL_HOST1 \nEXTERNAL_IP=$EXTERNAL_IP1 \nTAG=$TAG" > .env
- name: Deploy docker compose to a pre-configured server
id: deploy
uses: TapTap21/[email protected]
with:
remote_docker_host: ${{ secrets.RTC1_HOST }}
ssh_private_key: ${{ secrets.SSH_PRIV_KEY }}
ssh_public_key: ${{ secrets.SSH_PUB_KEY }}
docker_login_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
docker_login_user: ${{ secrets.DOCKER_HUB_USERNAME }}
docker_login_registry : https://index.docker.io/v1/
stack_file_name: ./backend/docker-compose.yml
args: -p rtc1 --env-file .env up -d --remove-orphans
# deploy-rtc2:
# runs-on: ubuntu-latest
# needs: build
# steps:
# - uses: actions/checkout@v2
# - name: Prepare .env file for the deployment
# id: variables_population
# run: printf "INTEGRATED_TURN_IP=$EXTERNAL_IP2 \nRELEASE_DISTRIBUTION=name \nRELEASE_NODE=$SNAME2@$PRIVATE_IP2 \nSECRET_KEY_BASE=$SECRET_KEY_BASE \nVIRTUAL_HOST=$VIRTUAL_HOST2 \nEXTERNAL_IP=$EXTERNAL_IP2 \nTAG=$TAG" > .env
# - name: Deploy docker compose to a pre-configured server
# id: deploy
# uses: TapTap21/[email protected]
# with:
# remote_docker_host: ${{ secrets.RTC2_HOST }}
# ssh_private_key: ${{ secrets.SSH_PRIV_KEY }}
# ssh_public_key: ${{ secrets.SSH_PUB_KEY }}
# docker_login_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
# docker_login_user: ${{ secrets.DOCKER_HUB_USERNAME }}
# docker_login_registry : https://index.docker.io/v1/
# stack_file_name: ./backend/docker-compose.yml
# args: -p rtc2 --env-file .env up -d --remove-orphans