Skip to content

Commit

Permalink
feat: deploy via waypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjules committed Apr 11, 2022
1 parent fd39c95 commit c78c471
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Dockerfile
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"]
57 changes: 57 additions & 0 deletions waypoint.hcl
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
}
}
}

0 comments on commit c78c471

Please sign in to comment.