Reconfigure to use Fly.io, update workflow
This commit is contained in:
parent
0442d9714c
commit
4e7ae85a35
50
.github/workflows/deploy_api.yml
vendored
50
.github/workflows/deploy_api.yml
vendored
|
|
@ -8,53 +8,21 @@ on:
|
|||
- api/**
|
||||
- .github/workflows/deploy_api.yml
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
name: Build Docker image and push to GitHub Container Registry
|
||||
name: Deploy to Fly.io
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: api
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
outputs:
|
||||
tag: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: docker/metadata-action@v4
|
||||
id: meta
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ github.repository }}/api
|
||||
- uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./api
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
deploy:
|
||||
needs: build-and-push
|
||||
name: Deploy to EC2
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.EC2_HOST }}
|
||||
username: ${{ secrets.EC2_USERNAME }}
|
||||
key: ${{ secrets.EC2_SSH_KEY }}
|
||||
script: |
|
||||
docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
|
||||
docker pull ${{ needs.build-and-push.outputs.tag }}
|
||||
docker stop crabfit-api
|
||||
docker rm crabfit-api
|
||||
docker run -d -p 3000:3000 --name crabfit-api --env-file ./.env ${{ needs.build-and-push.outputs.tag }}
|
||||
- uses: superfly/flyctl-actions/setup-flyctl@master
|
||||
- run: flyctl deploy --remote-only
|
||||
env:
|
||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||
|
|
|
|||
15
api/fly.toml
Normal file
15
api/fly.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# fly.toml app configuration file generated for crabfit-api on 2023-05-16T19:42:08+10:00
|
||||
#
|
||||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
||||
#
|
||||
# Note: this is used to deploy the production Crab Fit API to Fly.io
|
||||
|
||||
app = "crabfit-api"
|
||||
primary_region = "syd"
|
||||
|
||||
[http_service]
|
||||
internal_port = 3000
|
||||
force_https = true
|
||||
auto_stop_machines = true
|
||||
auto_start_machines = true
|
||||
min_machines_running = 0
|
||||
Loading…
Reference in a new issue