From 40dfad9b29b82aa95a1226269e977393e3407ae6 Mon Sep 17 00:00:00 2001 From: Mikkel Svartveit Date: Sat, 14 Sep 2024 17:15:32 +0200 Subject: [PATCH] Add Fly config --- .dockerignore | 34 ++++++++++++++++++++++++++++++++ .github/workflows/fly-deploy.yml | 18 +++++++++++++++++ Dockerfile | 22 +++++++++++++++++++++ fly.toml | 29 +++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/fly-deploy.yml create mode 100644 Dockerfile create mode 100644 fly.toml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..91d9235 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,34 @@ +# flyctl launch added from .gitignore +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +**/*.exe +**/*.exe~ +**/*.dll +**/*.so +**/*.dylib + +# Test binary, built with `go test -c` +**/*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +**/*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +**/go.work +**/go.work.sum + +# env file +**/.env + +**/tmp +**/data +**/node_modules + +# flyctl launch added from node_modules/.pnpm/tailwindcss@3.4.10/node_modules/tailwindcss/stubs/.gitignore +!node_modules/.pnpm/tailwindcss@3.4.10/node_modules/tailwindcss/stubs/**/* +fly.toml diff --git a/.github/workflows/fly-deploy.yml b/.github/workflows/fly-deploy.yml new file mode 100644 index 0000000..b0c246e --- /dev/null +++ b/.github/workflows/fly-deploy.yml @@ -0,0 +1,18 @@ +# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ + +name: Fly Deploy +on: + push: + branches: + - main +jobs: + deploy: + name: Deploy app + runs-on: ubuntu-latest + concurrency: deploy-group # optional: ensure only one action runs at a time + steps: + - uses: actions/checkout@v4 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12832a7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +ARG GO_VERSION=1 + +# Build stage +FROM golang:${GO_VERSION}-alpine as builder + +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download && go mod verify +COPY . . +RUN CGO_ENABLED=1 go build -v -o ./main ./src + + +# Production stage +FROM alpine:latest + +RUN apk --no-cache add ca-certificates + +COPY --from=builder /app/main /main +COPY --from=builder /app/templates /templates +COPY --from=builder /app/static /static + +CMD ["./main"] diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..eebf105 --- /dev/null +++ b/fly.toml @@ -0,0 +1,29 @@ +# fly.toml app configuration file generated for filtrert on 2024-09-14T16:59:40+02:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'filtrert' +primary_region = 'arn' + +[build] + [build.args] + GO_VERSION = '1.23.0' + +[env] + PORT = '8080' + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = 'stop' + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + size = 'shared-cpu-1x' + +[mounts] + source = 'data' + destination = '/data'