Compare commits

...

6 commits
v0.0.1 ... main

Author SHA1 Message Date
14470b3c0c fix image name 2025-03-02 18:52:27 +01:00
0713fcc887 fix release secret 2025-03-02 18:29:57 +01:00
aa4b4d7d3c 5.2 tag 2025-03-02 18:21:50 +01:00
d0126c97ff add docker builds 2025-03-02 15:10:35 +01:00
ba9e9ab9ab lint 2024-05-11 18:49:57 +02:00
8ab7522c55 fix ci 2024-05-11 16:06:15 +02:00
7 changed files with 63 additions and 6 deletions

3
.gitignore vendored
View file

@ -2,4 +2,5 @@
epee-service
dist/
dist/*
.DS_STORE
.DS_STORE
epee-*

32
.woodpecker/docker.yaml Normal file
View file

@ -0,0 +1,32 @@
steps:
- name: publish_image
image: woodpeckerci/plugin-docker-buildx:5.2
settings:
repo: git.gnous.eu/${CI_REPO_OWNER}/epee-service
dockerfile: Dockerfile
platforms: linux/amd64
registry: https://git.gnous.eu
tag: ${CI_COMMIT}
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push
- name: publish_image_tag
image: woodpeckerci/plugin-docker-buildx:5.2
settings:
repo: git.gnous.eu/${CI_REPO_OWNER}/epee-service
dockerfile: Dockerfile
platforms: linux/amd64
registry: https://git.gnous.eu
tags:
- ${CI_COMMIT_TAG##v} # Remove v from tag
- stable
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event: tag

View file

@ -1,6 +1,6 @@
steps:
lint:
image: golang:1.22
image: golang:1.24
commands:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- golangci-lint run

View file

@ -1,8 +1,9 @@
steps:
- name: Build
image: golang:1.22
image: golang:1.24
commands:
- go mod download
- go get
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o epee-linux-amd64 # Enable static binary, target Linux, remove debug information and strip binary
- CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-w -s" -o epee-linux-arm64
- CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "-w -s" -o epee-linux-arm
@ -15,7 +16,7 @@ steps:
files:
- "epee-*"
api_key:
from_secret: release_token
from_secret: gnous_cicd_token
target: main
when:
event: tag

17
Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM golang:1.24 AS builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app/
ADD . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o epee main.go
FROM scratch
WORKDIR /app/
COPY --from=builder /app/epee /app/epee
EXPOSE 5900
ENTRYPOINT ["/app/epee"]

2
go.sum
View file

@ -5,6 +5,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=

View file

@ -71,14 +71,18 @@ func errorHandler(w http.ResponseWriter, r *http.Request) {
generateInternalServerError(w, err)
return
}
t.Execute(w, errorData)
if err := t.Execute(w, errorData); err != nil {
log.Error(err)
}
}
func generateInternalServerError(w http.ResponseWriter, err error) {
log.Println(err)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(`{"error": "Internal Server Error"}`))
if _, err := w.Write([]byte(`{"error": "Internal Server Error"}`)); err != nil {
log.Error(err)
}
}
func headersHandler(w http.ResponseWriter, r *http.Request) {