This commit is contained in:
Kwitsch 2022-09-17 13:20:25 +02:00
parent 9a9fe1e9f1
commit 6a8c88ca81
2 changed files with 6 additions and 10 deletions

View File

@ -77,8 +77,6 @@ jobs:
- name: Prepare build cache
shell: bash
run: |
rm -Rf ./vendor
TOKEN64=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
JSON=$(curl -s -H "Authorization: Bearer ${TOKEN64}" https://ghcr.io/v2/${{ github.repository }}/tags/list | jq .)
CACHE_EXISTS=$(jq '[ .tags[]? | contains("buildcache") ] | any' <<< "$JSON")

View File

@ -1,7 +1,7 @@
# prepare build environment
FROM --platform=$BUILDPLATFORM ghcr.io/gythialy/golang-cross-builder:v1.19.1-0 AS build
# required arguments(target will be through buildx)
# required arguments(buildx will set target)
ARG VERSION
ARG BUILD_TIME
ARG TARGETOS
@ -13,20 +13,19 @@ ENV CGO_ENABLED=0
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
# add blocky user
RUN echo "blocky:x:100:65533:Blocky User,,,:/app:/sbin/nologin" > /tmp/blocky_passwd
#adduser -home /app -shell /sbin/nologin blocky && \
# tail -n 1 /etc/passwd > /tmp/blocky_passwd
# create blocky user passwd file
RUN echo "blocky:x:100:65533:Blocky User,,,:/app:/sbin/nologin" > /tmp/blocky_passw
# set working directory
WORKDIR /go/src
# add source
# download packages
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg \
go mod download
ADD . .
# add source
COPY . .
# build binary
RUN --mount=type=cache,target=/root/.cache/go-build \
@ -41,7 +40,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
-v \
-ldflags="-linkmode external -extldflags -static -X github.com/0xERR0R/blocky/util.Version=${VERSION} -X github.com/0xERR0R/blocky/util.BuildTime=${BUILD_TIME}" \
-o /bin/blocky
# ,sharing=locked
RUN setcap 'cap_net_bind_service=+ep' /bin/blocky
RUN chown 100 /bin/blocky