Skip to content

Commit

Permalink
Merge pull request #36 from bldg14/kf/32-enable-auto-deploy
Browse files Browse the repository at this point in the history
enable auto deploy to fly.io of server
  • Loading branch information
kevinfalting authored Aug 31, 2023
2 parents 3ca1fa9 + db4dfd0 commit 70d64f7
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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/

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
15 changes: 15 additions & 0 deletions .github/workflows/fly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
25 changes: 25 additions & 0 deletions Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG GO_VERSION=1.21.0

FROM golang:${GO_VERSION} as builder

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates tzdata

RUN adduser --system --group nonrootuser

WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build --trimpath -o ./bin/eventual ./cmd/eventual
RUN chown nonrootuser:nonrootuser ./bin/eventual

FROM scratch

COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder --chown=nonrootuser:nonrootuser /src/bin/eventual /bin/eventual

USER nonrootuser
EXPOSE 8080
ENTRYPOINT ["/bin/eventual"]
18 changes: 18 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# fly.toml app configuration file generated for eventual on 2023-08-24T19:13:07-05:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "eventual"
primary_region = "dfw"

[build]
dockerfile = "Dockerfile.server"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

0 comments on commit 70d64f7

Please sign in to comment.