mirror of
https://github.com/mentos1386/zdravko.git
synced 2025-04-21 04:53:37 +00:00
ci(build): deployment fixes
This commit is contained in:
parent
7699acea6f
commit
b1a766f9b6
10 changed files with 78 additions and 29 deletions
|
@ -1,3 +0,0 @@
|
||||||
build
|
|
||||||
deploy
|
|
||||||
docs
|
|
|
@ -12,12 +12,12 @@ RUN go mod download
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
RUN CGO_ENABLED=1 GOOS=linux go build -o /zdravko cmd/zdravko/main.go
|
RUN CGO_ENABLED=1 GOOS=linux go build -o /bin/zdravko cmd/zdravko/main.go
|
||||||
|
|
||||||
###
|
###
|
||||||
# Final production
|
# Final production
|
||||||
FROM gcr.io/distroless/base-debian12:nonroot as production
|
FROM debian:12-slim as production
|
||||||
COPY --from=builder /zdravko /zdravko
|
COPY --from=builder /bin/zdravko /bin/zdravko
|
||||||
COPY LICENSE /LICENSE
|
COPY LICENSE /LICENSE
|
||||||
COPY README.md /README.md
|
COPY README.md /README.md
|
||||||
|
|
||||||
|
|
|
@ -86,10 +86,12 @@ func main() {
|
||||||
for sig := range c {
|
for sig := range c {
|
||||||
log.Printf("Received signal: %v", sig)
|
log.Printf("Received signal: %v", sig)
|
||||||
for _, s := range servers {
|
for _, s := range servers {
|
||||||
println("Stopping", s.Name())
|
if s != nil {
|
||||||
err := s.Stop()
|
println("Stopping", s.Name())
|
||||||
if err != nil {
|
err := s.Stop()
|
||||||
log.Fatalf("Unable to stop server %s: %v", s.Name(), err)
|
if err != nil {
|
||||||
|
log.Fatalf("Unable to stop server %s: %v", s.Name(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
ARG ALPINE_VERSION=3.14
|
ARG ZDRAVKO_VERSION=main
|
||||||
|
|
||||||
|
FROM ghcr.io/mentos1386/zdravko:${ZDRAVKO_VERSION}
|
||||||
|
RUN apt-get update -y \
|
||||||
|
&& apt-get install -y ca-certificates fuse3 sqlite3
|
||||||
|
|
||||||
FROM alpine:${ALPINE_VERSION} as temporal
|
|
||||||
RUN apk add ca-certificates fuse3 sqlite
|
|
||||||
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs
|
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs
|
||||||
COPY litefs.yaml /etc/litefs.yaml
|
|
||||||
|
|
||||||
COPY --from=ghcr.io/mentos1386/zdravko /zdravko /zdravko
|
COPY deploy/litefs.yaml /etc/litefs.yml
|
||||||
|
COPY deploy/entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT litefs mount
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
14
deploy/entrypoint.sh
Executable file
14
deploy/entrypoint.sh
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PROCESS=${FLY_PROCESS_GROUP}
|
||||||
|
|
||||||
|
if [ "$PROCESS" = "server" ]; then
|
||||||
|
echo "Starting server process"
|
||||||
|
exec litefs mount -- $@
|
||||||
|
elif [ "$PROCESS" = "worker" ]; then
|
||||||
|
echo "Starting worker process"
|
||||||
|
exec $@
|
||||||
|
else
|
||||||
|
echo "Unknown process"
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -5,6 +5,7 @@ primary_region = 'waw'
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
dockerfile = "Dockerfile"
|
dockerfile = "Dockerfile"
|
||||||
|
context = "deploy"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
ROOT_URL = 'https://zdravko.mnts.dev'
|
ROOT_URL = 'https://zdravko.mnts.dev'
|
||||||
|
@ -17,8 +18,8 @@ primary_region = 'waw'
|
||||||
TEMPORAL_SERVER_HOST = 'server.process.zdravko.internal:7233'
|
TEMPORAL_SERVER_HOST = 'server.process.zdravko.internal:7233'
|
||||||
|
|
||||||
[processes]
|
[processes]
|
||||||
server = "zdravko --temporal=true --server=true --worker=false"
|
server = "/zdravko --temporal=true --server=true --worker=false"
|
||||||
worker = "zdravko --temporal=false --server=false --worker=true"
|
worker = "/zdravko --temporal=false --server=false --worker=true"
|
||||||
|
|
||||||
[[mounts]]
|
[[mounts]]
|
||||||
source = "zdravko_data"
|
source = "zdravko_data"
|
||||||
|
|
|
@ -7,9 +7,6 @@ fuse:
|
||||||
data:
|
data:
|
||||||
dir: "/var/lib/litefs"
|
dir: "/var/lib/litefs"
|
||||||
|
|
||||||
exec:
|
|
||||||
- cmd: "/zdravko --temporal=true --server=true --worker=false"
|
|
||||||
|
|
||||||
lease:
|
lease:
|
||||||
type: "consul"
|
type: "consul"
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,16 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HealtcheckHttpActivityParam struct {
|
type HealtcheckHttpParam struct {
|
||||||
Url string
|
Url string
|
||||||
Method string
|
Method string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HealthcheckHttpActivityResult struct {
|
type HealthcheckHttpResult struct {
|
||||||
StatusCode int
|
StatusCode int
|
||||||
}
|
}
|
||||||
|
|
||||||
func HealthcheckHttpActivityDefinition(ctx context.Context, param HealtcheckHttpActivityParam) (*HealthcheckHttpActivityResult, error) {
|
func HealthcheckHttp(ctx context.Context, param HealtcheckHttpParam) (*HealthcheckHttpResult, error) {
|
||||||
if param.Method == "" {
|
if param.Method == "" {
|
||||||
param.Method = "GET"
|
param.Method = "GET"
|
||||||
}
|
}
|
||||||
|
@ -38,5 +38,40 @@ func HealthcheckHttpActivityDefinition(ctx context.Context, param HealtcheckHttp
|
||||||
|
|
||||||
log.Printf("HealthcheckHttpActivityDefinition produced statuscode %d for url %s", response.StatusCode, param.Url)
|
log.Printf("HealthcheckHttpActivityDefinition produced statuscode %d for url %s", response.StatusCode, param.Url)
|
||||||
|
|
||||||
return &HealthcheckHttpActivityResult{StatusCode: response.StatusCode}, nil
|
return &HealthcheckHttpResult{StatusCode: response.StatusCode}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type HealtcheckHttpAddToHistoryParam struct {
|
||||||
|
Id string
|
||||||
|
Success bool
|
||||||
|
StatusCode int
|
||||||
|
}
|
||||||
|
|
||||||
|
type HealthcheckHttpAddToHistoryResult struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func HealthcheckHttpWriteResult(ctx context.Context, param HealtcheckHttpParam) (*HealthcheckHttpResult, error) {
|
||||||
|
if param.Method == "" {
|
||||||
|
param.Method = "GET"
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
response *http.Response
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
switch param.Method {
|
||||||
|
case "GET":
|
||||||
|
response, err = http.Get(param.Url)
|
||||||
|
case "POST":
|
||||||
|
response, err = http.Post(param.Url, "application/json", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("HealthcheckHttpActivityDefinition produced statuscode %d for url %s", response.StatusCode, param.Url)
|
||||||
|
|
||||||
|
return &HealthcheckHttpResult{StatusCode: response.StatusCode}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@ func HealthcheckHttpWorkflowDefinition(ctx workflow.Context, param HealthcheckHt
|
||||||
}
|
}
|
||||||
ctx = workflow.WithActivityOptions(ctx, options)
|
ctx = workflow.WithActivityOptions(ctx, options)
|
||||||
|
|
||||||
activityParam := activities.HealtcheckHttpActivityParam{
|
activityParam := activities.HealtcheckHttpParam{
|
||||||
Url: param.Url,
|
Url: param.Url,
|
||||||
Method: param.Method,
|
Method: param.Method,
|
||||||
}
|
}
|
||||||
|
|
||||||
var result *activities.HealthcheckHttpActivityResult
|
var result *activities.HealthcheckHttpResult
|
||||||
err := workflow.ExecuteActivity(ctx, activities.HealthcheckHttpActivityDefinition, activityParam).Get(ctx, &result)
|
err := workflow.ExecuteActivity(ctx, activities.HealthcheckHttp, activityParam).Get(ctx, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (w *Worker) Start() error {
|
||||||
w.worker.RegisterWorkflow(workflows.HealthcheckHttpWorkflowDefinition)
|
w.worker.RegisterWorkflow(workflows.HealthcheckHttpWorkflowDefinition)
|
||||||
|
|
||||||
// Register Activities
|
// Register Activities
|
||||||
w.worker.RegisterActivity(activities.HealthcheckHttpActivityDefinition)
|
w.worker.RegisterActivity(activities.HealthcheckHttp)
|
||||||
|
|
||||||
return w.worker.Run(worker.InterruptCh())
|
return w.worker.Run(worker.InterruptCh())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue