Skip to content

Commit

Permalink
setup docker
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquepw committed Aug 4, 2024
1 parent 14439d5 commit 9e9997e
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 7 deletions.
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# flyctl launch added from .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

# go workspace file
**/go.work
**/.tmp
**/.testdata

# project build
**/main
**/*templ.go
**/static/output.css

# mac stuff
**/.DS_Store
18 changes: 18 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -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
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 }}
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ go.work
.tmp/
.testdata/

# IDE specific files
.vscode
.idea

# .env file
.env*
!.env.example
Expand All @@ -29,8 +25,5 @@ main
*templ.go
static/output.css

# deploy
fly.toml

# mac stuff
.DS_Store
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:alpine AS builder

WORKDIR /app
COPY . .
RUN wget -O tailwind https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.1/tailwindcss-linux-x64 && \
chmod +x tailwind && ./tailwind -i ./static/css/input.css -o ./static/css/output.css --minify

RUN go install github.com/a-h/templ/cmd/templ@latest && templ generate

RUN go build -o main ./cmd/main.go

FROM scratch
WORKDIR /app

COPY --from=builder app/static/ ./static/
COPY --from=builder app/main app/.env .
CMD ["./main"]
20 changes: 20 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
app = 'imperium-tattoo'
primary_region = 'gru'

[build]
[build.args]
GO_VERSION = '1.22.5'

[env]
PORT = '3000'

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

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

0 comments on commit 9e9997e

Please sign in to comment.