From 2c3a2be274c080430b62016cf393708648a78e7e Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Wed, 24 Apr 2024 09:39:03 +0200 Subject: [PATCH] Replace fly deployment with docker build --- .github/fly.toml | 55 ++++++++++++++++-------------- .github/workflows/deploy.yml | 66 ++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 62 deletions(-) diff --git a/.github/fly.toml b/.github/fly.toml index 07332eb..cc85592 100644 --- a/.github/fly.toml +++ b/.github/fly.toml @@ -1,42 +1,45 @@ -# fly.toml file generated for marda-registry on 2023-01-08T19:25:07Z +# fly.toml app configuration file generated for datatractor-yard on 2024-04-23T21:21:20+02:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# -app = "marda-registry" -kill_signal = "SIGINT" -kill_timeout = 5 -processes = [] +app = 'datatractor-yard' +primary_region = 'lhr' +kill_signal = 'SIGINT' +kill_timeout = '5s' + +[experimental] + auto_rollback = true [build] - builder = "paketobuildpacks/builder:base" + builder = 'paketobuildpacks/builder:base' [env] - PORT = "8080" - -[experimental] - allowed_public_ports = [] - auto_rollback = true + PORT = '8080' [[services]] - http_checks = [] + protocol = 'tcp' internal_port = 8080 - processes = ["app"] - protocol = "tcp" - script_checks = [] - [services.concurrency] - hard_limit = 25 - soft_limit = 20 - type = "connections" + processes = ['app'] [[services.ports]] - force_https = true - handlers = ["http"] port = 80 + handlers = ['http'] + force_https = true [[services.ports]] - handlers = ["tls", "http"] port = 443 + handlers = ['tls', 'http'] + + [services.concurrency] + type = 'connections' + hard_limit = 25 + soft_limit = 20 [[services.tcp_checks]] - grace_period = "1s" - interval = "15s" - restart_limit = 0 - timeout = "2s" + interval = '15s' + timeout = '2s' + grace_period = '1s' + +[[vm]] + size = 'shared-cpu-1x' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7337953..a760555 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,41 +1,35 @@ ---- -name: Deploy to Fly +name: Publish Docker image on release on: - push: - branches: - - main + release: + types: [published] jobs: - deploy-fly: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: openmsi/datatractor-yard + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - - runs-on: ubuntu-latest - if: github.repository_owner == 'datatractor' - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: true - - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - cache: pip - cache-dependency-path: pyproject.toml - - - name: Install dependencies - run: pip install -r requirements.txt - - - name: Generate Python models - run: invoke regenerate-models - - - name: Set up Fly - uses: superfly/flyctl-actions/setup-flyctl@master - - - name: Deploy to Fly - run: flyctl deploy --remote-only -c ./.github/fly.toml