Skip to content

Commit

Permalink
add deploy config and action for fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
willnorris committed Feb 23, 2024
1 parent 07cd52d commit 11ef700
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: deploy
on:
push:
branches:
- "main"
workflow_dispatch:
repository_dispatch:
types: [deploy]

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl -c cmd/gomfweb/fly.toml deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
21 changes: 21 additions & 0 deletions cmd/gomfweb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM --platform=$BUILDPLATFORM cgr.dev/chainguard/wolfi-base:latest as build
RUN apk update && apk add build-base git openssh go-1.21

WORKDIR /work

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
ARG TARGETOS TARGETARCH
RUN GOOS=${TARGETOS} GOARCH="${TARGETARCH}" CGO_ENABLED=0 go build -v ./cmd/gomfweb

FROM cgr.dev/chainguard/static:latest

COPY --from=build /work/gomfweb /gomfweb

WORKDIR /
ENTRYPOINT ["/gomfweb"]
CMD []

EXPOSE 4001
19 changes: 19 additions & 0 deletions cmd/gomfweb/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To deploy, run this from the repo root:
#
# fly deploy -c cmd/gomfweb/fly.toml

app = 'microformats-go'
primary_region = 'sjc'

[build]
dockerfile = "Dockerfile"

[http_service]
internal_port = 4001
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0

[[vm]]
size = 'shared-cpu-1x'

0 comments on commit 11ef700

Please sign in to comment.