-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
FROM golang:1.18-alpine AS build | ||
|
||
# Environment Variables | ||
ENV CGO_ENABLED 0 | ||
ENV GOOS linux | ||
ENV GOARCH amd64 | ||
|
||
WORKDIR $HOME/github.com/JulesMike/spoty | ||
FROM golang:1.18-alpine AS builder | ||
|
||
# Add git, curl and upx support | ||
RUN apk add --update git curl upx | ||
RUN apk add --no-cache git curl upx | ||
|
||
WORKDIR /src | ||
|
||
# Pull modules | ||
COPY go.* ./ | ||
RUN go mod download | ||
|
||
# Copy code into image | ||
COPY . . | ||
COPY . ./ | ||
|
||
# Build application for deployment | ||
RUN go build -tags=jsoniter -trimpath -a -ldflags "-s -w -extldflags '-static'" \ | ||
-v -o /spoty . | ||
RUN CGO_ENABLED=0 go build -tags=jsoniter -trimpath -ldflags "-s -w" -o /tmp/spoty . | ||
|
||
# Compress binary | ||
RUN upx --best --lzma /spoty | ||
RUN upx --best --lzma /tmp/spoty | ||
|
||
# Create minimal image with just the application | ||
# gcr.io/distroless/static is perfect for Go app that do not depend on libc | ||
FROM gcr.io/distroless/static | ||
COPY --from=build /spoty / | ||
COPY --from=builder /tmp/spoty /spoty | ||
CMD ["/spoty", "serve"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
project = "spoty" | ||
|
||
|
||
variable "docker_username" { | ||
type = string | ||
} | ||
|
||
variable "docker_password" { | ||
type = string | ||
} | ||
|
||
runner { | ||
enabled = true | ||
profile = "kubernetes" | ||
|
||
data_source "git" { | ||
url = "https://github.com/JulesMike/spoty.git" | ||
ref = "main" | ||
} | ||
|
||
poll { | ||
enabled = true | ||
} | ||
} | ||
|
||
app "api" { | ||
labels = { | ||
"lang" = "go" | ||
} | ||
|
||
build { | ||
use "docker" { | ||
buildkit = false | ||
} | ||
|
||
registry { | ||
use "docker" { | ||
image = "julesmike/spoty" | ||
tag = gitrefpretty() | ||
username = var.docker_username | ||
password = var.docker_password | ||
} | ||
} | ||
} | ||
|
||
deploy { | ||
use "kubernetes" { | ||
service_port = 13337 | ||
} | ||
} | ||
|
||
release { | ||
use "kubernetes" { | ||
port = 8080 | ||
} | ||
} | ||
} |