From 586ee5a007ef3afdcfc572d7f8c96c4648b188e1 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 30 Apr 2023 18:13:11 +0200 Subject: [PATCH] [FORGEJO] build forgejo-runner --- .dockerignore | 2 ++ .gitignore | 4 +++- Dockerfile | 15 +++++++++++++++ Makefile | 10 +++------- 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7b6d2b2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +forgejo-runner diff --git a/.gitignore b/.gitignore index 38e1b26..3a3808c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -act_runner +*~ + +forgejo-runner .env .runner coverage.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0fdae4a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +#Build stage +FROM golang:1.20-alpine3.17 AS build-env + +RUN apk --no-cache add build-base git + +COPY . /srv +WORKDIR /srv +RUN make build + +FROM alpine:3.17 +LABEL maintainer="contact@forgejo.org" + +COPY --from=build-env /srv/forgejo-runner /bin/forgejo-runner + +ENTRYPOINT ["/bin/forgejo-runner"] diff --git a/Makefile b/Makefile index 454d2f5..4157810 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ DIST := dist -EXECUTABLE := act_runner +EXECUTABLE := forgejo-runner GOFMT ?= gofumpt -l DIST := dist DIST_DIRS := $(DIST)/binaries $(DIST)/release @@ -20,11 +20,7 @@ DOCKER_IMAGE ?= gitea/act_runner DOCKER_TAG ?= nightly DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG) -ifneq ($(shell uname), Darwin) - EXTLDFLAGS = -extldflags "-static" $(null) -else - EXTLDFLAGS = -endif +EXTLDFLAGS = -extldflags "-static" $(null) ifeq ($(HAS_GO), GO) GOPATH ?= $(shell $(GO) env GOPATH) @@ -116,7 +112,7 @@ install: $(GOFILES) build: go-check $(EXECUTABLE) $(EXECUTABLE): $(GOFILES) - $(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@ + $(GO) build -v -tags 'netgo osusergo $(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@ .PHONY: deps-backend deps-backend: