Skip to content

Commit

Permalink
serve public folder via fly
Browse files Browse the repository at this point in the history
  • Loading branch information
Bios-Marcel committed Dec 22, 2024
1 parent 0bf4249 commit 6cc8be8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
!linux.Dockerfile
!windows.Dockerfile

!public

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ playground/
*.tmp
# Profiling results
*.pprof
# Additional files for hosting. Workaround for now ig.
public/
38 changes: 38 additions & 0 deletions fly.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Builder for Golang
#
# We explicitly use a certain major version of go, to make sure we don't build
# with a newer verison than we are using for CI tests, as we don't directly
# test the produced binary but from source code directly.
FROM docker.io/golang:1.23.3 AS builder

WORKDIR /app

# This causes caching of the downloaded go modules and makes repeated local
# builds much faster. We must not copy the code first though, as a change in
# the code causes a redownload.
COPY go.mod go.sum ./
RUN go mod download -x

# Import that this comes after mod download, as it breaks caching.
ARG VERSION="dev"

# Copy actual codebase, since we only have the go.mod and go.sum so far.
COPY . /app/
ENV CGO_ENABLED=0
RUN go build -trimpath -ldflags "-w -s -X 'github.com/scribble-rs/scribble.rs/internal/version.Version=${VERSION}'" -tags timetzdata -o ./scribblers ./cmd/scribblers

#
# Runner
#
FROM scratch

# Additionally hosted files
COPY public /public

COPY --from=builder /app/scribblers /scribblers
# The scratch image doesn't contain any certificates, therefore we use
# the builders certificate, so that we can send HTTP requests.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT ["/scribblers"]
9 changes: 5 additions & 4 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ port = 8080
path = "/v1/metrics"

[build]
dockerfile = "linux.Dockerfile"
dockerfile = "fly.Dockerfile"

[deploy]
strategy = "canary"
strategy = "immediate"

[env]
ROOT_URL = "https://scribblers.bios-marcel.link"
LOBBY_SETTING_BOUNDS_MAX_MAX_PLAYERS = 100
ROOT_URL = "https://scribblers.bios-marcel.link"
SERVE_DIRECTORIES = ":/public"
LOBBY_SETTING_BOUNDS_MAX_MAX_PLAYERS = 100

[http_service]
internal_port = 8080
Expand Down

0 comments on commit 6cc8be8

Please sign in to comment.