Skip to content

Commit

Permalink
Created goreleaser dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
satr committed Sep 20, 2022
1 parent cd99fbd commit c2b3dcd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ builds:
- arm64
dockers:
- image_templates:
- "docker.pkg.github.com/equinor/radix-cli/rx:latest"
dockerfile: Dockerfile
- "ghcr.io/equinor/radix/rx:latest"
dockerfile: Dockerfile.goreleaser
ids:
- rx
archives:
Expand Down
42 changes: 37 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
FROM alpine:3.16.2
RUN apk update && apk add ca-certificates && apk add bash && rm -rf /var/cache/apk/*
FROM golang:1.18.5-alpine3.16 as builder

RUN addgroup -S -g 1000 radix && adduser -S -u 1000 -G radix radix
ENV GO111MODULE=on

RUN apk update && \
apk add bash jq alpine-sdk sed gawk git ca-certificates curl mc && \
apk add --no-cache gcc musl-dev
RUN go install honnef.co/go/tools/cmd/[email protected] && \
go install github.com/rakyll/[email protected] && \
go install github.com/golang/mock/[email protected] && \
go install github.com/go-swagger/go-swagger/cmd/[email protected]

WORKDIR /app
COPY rx /app/rx

# Install project dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy project code
COPY . /app

# lint and unit tests
RUN staticcheck ./... && \
go vet ./... && \
CGO_ENABLED=0 GOOS=linux go test ./...

RUN addgroup -S -g 1000 radix && adduser -S -u 1000 -G radix radix

# Build
RUN swagger generate client -t ./generated-client -f https://api.radix.equinor.com/swaggerui/swagger.json -A radixapi && \
go mod tidy && \
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o ./rootfs/rx

## Run operator
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /app/rootfs/rx /usr/local/bin/rx
USER 1000
ENTRYPOINT ["/app/rx"]
ENTRYPOINT ["/usr/local/bin/rx"]

9 changes: 9 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM alpine:3.16.2
RUN apk update && apk add ca-certificates && apk add bash && rm -rf /var/cache/apk/*

RUN addgroup -S -g 1000 radix && adduser -S -u 1000 -G radix radix

WORKDIR /app
COPY rx /app/rx
USER 1000
ENTRYPOINT ["/app/rx"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ release:

.PHONY: push
push:
docker build . -t ghcr.io/equinor/radix-cli/rx:latest
docker build . -t ghcr.io/equinor/radix/rx:latest
docker login ghcr.io/equinor
docker push ghcr.io/equinor/radix-cli/rx:latest
docker push ghcr.io/equinor/radix/rx:latest

0 comments on commit c2b3dcd

Please sign in to comment.