mirror of https://github.com/0xERR0R/blocky.git
test
This commit is contained in:
parent
7ae65caa0f
commit
e528ae66b3
54
Dockerfile
54
Dockerfile
|
@ -1,5 +1,5 @@
|
|||
# prepare build environment
|
||||
FROM --platform=$BUILDPLATFORM golang:1-alpine AS build
|
||||
FROM --platform=$BUILDPLATFORM golang:buster AS build
|
||||
|
||||
ARG VERSION
|
||||
ARG BUILD_TIME
|
||||
|
@ -7,27 +7,21 @@ ARG TARGETOS
|
|||
ARG TARGETARCH
|
||||
|
||||
# add blocky user
|
||||
RUN adduser -S -D -H -h /app -s /sbin/nologin blocky
|
||||
RUN tail -n 1 /etc/passwd > /tmp/blocky_passwd
|
||||
#RUN adduser -home /app -shell /sbin/nologin blocky && \
|
||||
# tail -n 1 /etc/passwd > /tmp/blocky_passwd
|
||||
|
||||
# add packages
|
||||
RUN apk add --no-cache \
|
||||
build-base \
|
||||
linux-headers \
|
||||
coreutils \
|
||||
binutils \
|
||||
libtool \
|
||||
musl-dev \
|
||||
git \
|
||||
make \
|
||||
gcc \
|
||||
libc-dev \
|
||||
zip \
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
dpkg --add-architecture armhf && \
|
||||
dpkg --add-architecture armel && \
|
||||
apt-get update && \
|
||||
apt-get --no-install-recommends install -y \
|
||||
ca-certificates \
|
||||
libcap
|
||||
|
||||
# setup environment
|
||||
ENV CGO_ENABLED=0
|
||||
build-essential \
|
||||
cross-gcc-dev \
|
||||
crossbuild-essential-armhf \
|
||||
crossbuild-essential-armel
|
||||
|
||||
# set working directory
|
||||
WORKDIR /go/src
|
||||
|
@ -37,18 +31,20 @@ ADD . .
|
|||
RUN go generate ./...
|
||||
|
||||
# build binary
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
RUN --mount=target=. \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg \
|
||||
CGO_ENABLED=0 \
|
||||
GOOS=$TARGETOS \
|
||||
GOARCH=$TARGETARCH \
|
||||
go build \
|
||||
-tags static \
|
||||
-v \
|
||||
-ldflags="-linkmode external -extldflags -static -X github.com/0xERR0R/blocky/util.Version=${VERSION} -X github.com/0xERR0R/blocky/util.BuildTime=${BUILD_TIME}" \
|
||||
-o /go/src/bin/blocky
|
||||
-o /bin/blocky
|
||||
|
||||
RUN setcap 'cap_net_bind_service=+ep' /go/src/bin/blocky && \
|
||||
chown blocky /go/src/bin/blocky
|
||||
RUN setcap 'cap_net_bind_service=+ep' /bin/blocky
|
||||
#chown blocky /bin/blocky
|
||||
|
||||
# final stage
|
||||
FROM scratch
|
||||
|
@ -57,13 +53,15 @@ LABEL org.opencontainers.image.source="https://github.com/0xERR0R/blocky" \
|
|||
org.opencontainers.image.url="https://github.com/0xERR0R/blocky" \
|
||||
org.opencontainers.image.title="DNS proxy as ad-blocker for local network"
|
||||
|
||||
COPY --from=build /tmp/blocky_passwd /etc/passwd
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=build /go/src/bin/blocky /app/blocky
|
||||
|
||||
USER blocky
|
||||
WORKDIR /app
|
||||
|
||||
# COPY --from=build /tmp/blocky_passwd /etc/passwd
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=build /bin/blocky /app/blocky
|
||||
|
||||
#USER blocky
|
||||
|
||||
|
||||
ENV BLOCKY_CONFIG_FILE=/app/config.yml
|
||||
|
||||
ENTRYPOINT ["/app/blocky"]
|
||||
|
|
Loading…
Reference in New Issue