Alpine build works, without version injection
parent
2524fd772a
commit
755c213b91
@ -1,10 +1,39 @@
|
|||||||
FROM golang:latest AS builder
|
# syntax=docker/dockerfile:1
|
||||||
ADD . /opt/obp
|
|
||||||
WORKDIR /opt/obp
|
# Build the application from source
|
||||||
|
FROM golang:latest AS build-stage
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
# This definitely works
|
||||||
|
# RUN CGO_ENABLED=0 GOOS=linux go build -o obp ./cmd/obp/
|
||||||
RUN make build-alpine
|
RUN make build-alpine
|
||||||
|
|
||||||
FROM alpine:latest
|
|
||||||
RUN apk --no-cache add ca-certificates
|
# Deploy the application binary into a lean image
|
||||||
ARG VERSION=*
|
FROM alpine:latest AS build-release-stage
|
||||||
COPY --from=builder /opt/obp/dist/obp-$VERSION-alpine_amd64/obp /bin/obp
|
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
ARG VERSION=version
|
||||||
|
COPY --from=build-stage /app/dist/*-alpine/obp /bin/obp
|
||||||
RUN chmod +x /bin/obp
|
RUN chmod +x /bin/obp
|
||||||
|
|
||||||
|
ARG USER=default
|
||||||
|
ENV HOME /home/$USER
|
||||||
|
|
||||||
|
# install sudo as root
|
||||||
|
RUN apk add --update sudo
|
||||||
|
|
||||||
|
# add new user
|
||||||
|
RUN adduser -D $USER \
|
||||||
|
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER \
|
||||||
|
&& chmod 0440 /etc/sudoers.d/$USER
|
||||||
|
|
||||||
|
USER $USER
|
||||||
|
WORKDIR $HOME
|
||||||
|
Loading…
Reference in New Issue