runner: update deploy workflow to push docker image to registry and deploy using docker compose
This commit is contained in:
parent
0498985f51
commit
e1147efbd9
|
@ -1,9 +1,7 @@
|
|||
# on:
|
||||
# push:
|
||||
# tags:
|
||||
# - "v*"
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
|
@ -12,4 +10,9 @@ jobs:
|
|||
image: docker:26.1.2
|
||||
|
||||
steps:
|
||||
- run: echo "Testing ${{ github.ref_name }}"
|
||||
- run: echo "Deploying version ${{ github.ref_name }}"
|
||||
- run: docker build -t git.tigor.web.id/tigor/redmage:${{ github.ref_name }} .
|
||||
- run: docker build -t git.tigor.web.id/tigor/redmage:latest .
|
||||
- run: docker push git.tigor.web.id/tigor/redmage:${{ github.ref_name }}
|
||||
- run: docker push git.tigor.web.id/tigor/redmage:latest
|
||||
- run: docker compose up -d
|
||||
|
|
|
@ -15,8 +15,8 @@ COPY go.mod go.sum ./
|
|||
RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=web-builder /web/public ./public
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
./bin/templ generate && GOOS=linux GOARCH=amd64 go build -o /app/redmage main.go
|
||||
ENV REDMAGE_RUNTIME_VERSION=unknown
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build make build-docker
|
||||
|
||||
|
||||
FROM gcr.io/distroless/base:nonroot
|
||||
|
|
10
Makefile
10
Makefile
|
@ -10,10 +10,9 @@ export GOOSE_MIGRATION_DIR=db/migrations
|
|||
export REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION=$(shell echo "$${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION:-1.9.12}")
|
||||
export REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION=$(shell echo "$${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION:-1.11.10}")
|
||||
export REDMAGE_WEB_DEPENDENCIES_ALPINEJS_VERSION=$(shell echo "$${REDMAGE_WEB_DEPENDENCIES_ALPINEJS_VERSION:-3.13.10}")
|
||||
export REDMAGE_RUNTIME_VERSION=$(shell echo "$${REDMAGE_RUNTIME_VERSION:-unknown}")
|
||||
|
||||
start: dev-dependencies
|
||||
@tailwindcss -i views/style.css -o public/style.css --watch &
|
||||
@templ generate -watch &
|
||||
air
|
||||
|
||||
dev-dependencies: build-dependencies
|
||||
|
@ -83,8 +82,11 @@ web-build: web-dependencies
|
|||
build: web-dependencies build-dependencies prepare
|
||||
go build -o redmage
|
||||
|
||||
build-docker: migrate-up
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o redmage
|
||||
build-docker:
|
||||
goose up
|
||||
templ generate
|
||||
go run github.com/stephenafamo/bob/gen/bobgen-sqlite@latest
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X 'github.com/tigorlazuardi/redmage/config.Version=${REDMAGE_RUNTIME_VERSION}'" -o redmage
|
||||
|
||||
prepare: gen
|
||||
mkdir -p public
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"github.com/adrg/xdg"
|
||||
)
|
||||
|
||||
var Version string = "unknown"
|
||||
|
||||
var DefaultConfig = map[string]any{
|
||||
"flags.containerized": false,
|
||||
|
||||
|
@ -60,6 +62,6 @@ var DefaultConfig = map[string]any{
|
|||
"web.dependencies.dayjs.version": "1.11.10",
|
||||
"web.dependencies.alpinejs.version": "3.13.10",
|
||||
|
||||
"runtime.version": "0.0.1",
|
||||
"runtime.version": Version,
|
||||
"runtime.environment": "development",
|
||||
}
|
||||
|
|
|
@ -27,8 +27,10 @@ func (srv *Server) Start(exit <-chan struct{}) error {
|
|||
caller := caller.New(3)
|
||||
go func() {
|
||||
log.New(context.Background()).Caller(caller).Info(
|
||||
"starting http server", "address", "http://"+srv.server.Addr,
|
||||
"starting http server",
|
||||
"address", "http://"+srv.server.Addr,
|
||||
"outbound_ip", "http://"+GetOutboundIP().String()+":"+srv.config.String("http.port"),
|
||||
"version", srv.config.String("runtime.version"),
|
||||
)
|
||||
errch <- srv.server.ListenAndServe()
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue