Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ language:
command: /go/bin/app
fasthttp:
command: /go/bin/app
gogo:
command: /go/bin/app

framework:
engines:
Expand Down
73 changes: 73 additions & 0 deletions go/gogo.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{#language.version}}
FROM golang:{{{.}}} AS build
{{/language.version}}
{{^language.version}}
FROM golang:1.26 AS build
{{/language.version}}

WORKDIR /go/src/app

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update && \
apt-get -qy install --no-install-recommends \
build-essential \
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*

ENV CGO_ENABLED=1 \
GOOS=linux \
GOARCH={{#architecture}}{{{.}}}{{/architecture}}

{{#if.architecture.amd64}}
# This compile with v3 micoarchitecture, since used proc is zen2 compatible ( AMD Ryzen 7 5700U)
# See https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
ENV GOAMD64=v3
{{/if.architecture.amd64}}

{{#if.architecture.arm64}}
# Use arm 8.5 instrctions set
# See https://en.wikipedia.org/wiki/Apple_M1
ENV GOARM64=v8.5
{{/if.architecture.arm64}}

{{#files}}
COPY '{{source}}' '{{target}}'
{{/files}}

{{#bootstrap}}
RUN {{{.}}}
{{/bootstrap}}

RUN --mount=type=cache,id=gomod-{{language.version}},target=/go/pkg/mod \
go get

RUN --mount=type=cache,id=gomod-{{language.version}},target=/go/pkg/mod \
--mount=type=cache,id=gobuild-{{language.version}},target=/root/.cache/go-build \
go build -trimpath {{#build_tags}} -tags {{{.}}} {{/build_tags}} -o /go/bin/app ./



FROM debian:trixie-slim

WORKDIR /go/bin

RUN apt-get -qq update && \
apt-get -qy install --no-install-recommends \
curl \
libstdc++6 \
zlib1g && \
rm -rf /var/lib/apt/lists/*

COPY --from=build /go/bin/app /go/bin/app

{{#environment}}
ENV {{{.}}}
{{/environment}}

{{#static_files}}
COPY '{{source}}' '{{target}}'
{{/static_files}}

HEALTHCHECK CMD curl --fail http://0.0.0.0:3000 || exit 1

ENTRYPOINT {{{command}}}
9 changes: 9 additions & 0 deletions go/gogo/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
framework:
github: Snocko-main/gogo
version: 0.1.0

build_tags:
- gogo

engines:
- gogo
3 changes: 3 additions & 0 deletions go/gogo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module main

require github.com/Snocko-main/gogo v0.1.0
35 changes: 35 additions & 0 deletions go/gogo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"log"
"runtime"

gogo "github.com/Snocko-main/gogo"
)

func main() {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

app, err := gogo.NewApp()
if err != nil {
log.Fatal(err)
}
defer app.Close()

app.Get("/", gogo.Reply{Status: 200})

app.Get("/user/:id", func(res *gogo.Response, req *gogo.Request) {
res.Send(200, "text/plain; charset=utf-8", req.Parameter(0))
})

app.Post("/user", func(res *gogo.Response, req *gogo.Request) {
res.Send(200, "", "")
})

if !app.Listen(3000) {
log.Fatal("failed to listen on :3000")
}

app.Run()
}
Loading