Skip to content

Commit

Permalink
moves the build process to Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
gbuenodevsuse committed Jan 14, 2025
1 parent a3a4097 commit 7f6db88
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
FROM registry.suse.com/bci/bci-micro:15.6
FROM golang:1.22.0 as build

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

ENV CGO_ENABLED=0

RUN VERSION=$(git describe --tags --always) \
ARCH=$(go env GOARCH) \
SUFFIX="-${ARCH}" \
LINKFLAGS="-X github.com/rancher/csp-adapter.Version=$VERSION" && \
go build -ldflags "$LINKFLAGS -extldflags -static -s" -o bin/csp-adapter

FROM registry.suse.com/bci/bci-micro:15.6 as final

ARG user=adapter

Expand All @@ -7,7 +25,7 @@ RUN echo "$user:x:1000:1000::/home/$user:/bin/bash" >> /etc/passwd && \
mkdir /home/$user && \
chown -R $user:$user /home/$user

COPY bin/csp-adapter /usr/bin/
COPY --from=build /app/bin/csp-adapter /usr/bin/

USER $user

Expand Down

0 comments on commit 7f6db88

Please sign in to comment.