Skip to content
name: Build Docker Images, Push to Registry, and Deploy to Production
on: push
# on:
# push:
# branches:
# - main
# release:
# types: [published]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [backend, realtime-evaluators, frontend]
steps:
- name: Check out the private Ops repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
submodules: "recursive"
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "lunary/lunary"
- name: Build ${{ matrix.service }}
uses: docker/build-push-action@v5
with:
context: .
file: ./ops/${{ matrix.service }}.Dockerfile
tags: |
lunary/${{ matrix.service }}:latest
lunary/${{ matrix.service }}:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }}
${{ github.event.release.tag_name != '' && format('lunary/{0}:{1}', matrix.service, steps.release_tag.outputs.tag) || '' }}
platforms: linux/arm64,linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
# push:
# needs: build
# runs-on: ubuntu-latest
# strategy:
# matrix:
# service: [backend, realtime-evaluators, frontend]
# steps:
# - name: Check out the private Ops repo
# uses: actions/checkout@v4
# with:
# token: ${{ secrets.GH_TOKEN }}
# submodules: "recursive"
# - name: Log in to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# version: "lab:latest"
# driver: cloud
# endpoint: "lunary/lunary"
# - name: Build ${{ matrix.service }}
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./ops/${{ matrix.service }}.Dockerfile
# push: push
# tags: |
# lunary/${{ matrix.service }}:latest
# lunary/${{ matrix.service }}:rev-${{ steps.date.outputs.date }}-${{ steps.commit.outputs.hash }}
# ${{ github.event.release.tag_name != '' && format('lunary/{0}:{1}', matrix.service, steps.release_tag.outputs.tag) || '' }}
# platforms: linux/arm64,linux/amd64
# cache-from: type=gha
# cache-to: type=gha,mode=max
# deploy:
# needs: push
# runs-on: ubuntu-latest
# steps:
# - name: Deploy to Production
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.PRODUCTION_IP_ADDRESS }}
# username: root
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# port: ${{ secrets.PRODUCTION_PORT }}
# script: |
# docker image prune -f
# cd /opt/lunary
# docker compose pull
# docker compose down
# docker compose up -d