Skip to content

Commit

Permalink
style: improve dockerfile readability (#627)
Browse files Browse the repository at this point in the history
Improve readability, preparing for possible future changes.
  • Loading branch information
jooola authored Jun 21, 2024
1 parent c53658e commit 1785485
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 17 deletions.
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM alpine:3.15
RUN apk add --no-cache ca-certificates e2fsprogs xfsprogs blkid xfsprogs-extra e2fsprogs-extra btrfs-progs cryptsetup

RUN apk add --no-cache \
blkid \
btrfs-progs \
ca-certificates \
cryptsetup \
e2fsprogs \
e2fsprogs-extra \
xfsprogs \
xfsprogs-extra

COPY ./controller.bin /bin/hcloud-csi-driver-controller
COPY ./node.bin /bin/hcloud-csi-driver-node
27 changes: 21 additions & 6 deletions deploy/docker-swarm/pkg/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
FROM --platform=$TARGETPLATFORM golang:1.21 as builder
WORKDIR /csi
ADD go.mod go.sum /csi/

WORKDIR /build

ADD go.mod go.sum /build/
RUN go mod download
ADD . /csi/

ADD . /build/
RUN ls -al
RUN CGO_ENABLED=0 go build -o aio.bin github.com/hetznercloud/csi-driver/cmd/aio

ARG CGO_ENABLED=0
RUN go build -o aio.bin github.com/hetznercloud/csi-driver/cmd/aio

FROM --platform=$TARGETPLATFORM alpine:3.15
RUN apk add --no-cache ca-certificates e2fsprogs xfsprogs blkid xfsprogs-extra e2fsprogs-extra btrfs-progs cryptsetup

RUN apk add --no-cache \
blkid \
btrfs-progs \
ca-certificates \
cryptsetup \
e2fsprogs \
e2fsprogs-extra \
xfsprogs \
xfsprogs-extra

ENV GOTRACEBACK=all
RUN mkdir -p /plugin
COPY --from=builder /csi/aio.bin /plugin
COPY --from=builder /build/aio.bin /plugin

ENTRYPOINT [ "/plugin/aio.bin" ]
34 changes: 26 additions & 8 deletions hack/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
FROM golang:1.21 as builder
WORKDIR /csi
ADD go.mod go.sum /csi/

WORKDIR /build

ADD go.mod go.sum /build/
RUN go mod download
ADD . /csi/

ADD . /build/
RUN ls -al

ARG GOOS=linux
ARG GOARCH=amd64
ARG CGO_ENABLED=0
# `skaffold debug` sets SKAFFOLD_GO_GCFLAGS to disable compiler optimizations
ARG SKAFFOLD_GO_GCFLAGS
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o controller.bin github.com/hetznercloud/csi-driver/cmd/controller
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o node.bin github.com/hetznercloud/csi-driver/cmd/node

RUN go build -gcflags="$SKAFFOLD_GO_GCFLAGS" -o controller.bin github.com/hetznercloud/csi-driver/cmd/controller
RUN go build -gcflags="$SKAFFOLD_GO_GCFLAGS" -o node.bin github.com/hetznercloud/csi-driver/cmd/node

FROM alpine:3.15
RUN apk add --no-cache ca-certificates e2fsprogs xfsprogs blkid xfsprogs-extra e2fsprogs-extra btrfs-progs cryptsetup

RUN apk add --no-cache \
blkid \
btrfs-progs \
ca-certificates \
cryptsetup \
e2fsprogs \
e2fsprogs-extra \
xfsprogs \
xfsprogs-extra

ENV GOTRACEBACK=all
COPY --from=builder /csi/controller.bin /bin/hcloud-csi-driver-controller
COPY --from=builder /csi/node.bin /bin/hcloud-csi-driver-node
COPY --from=builder /build/controller.bin /bin/hcloud-csi-driver-controller
COPY --from=builder /build/node.bin /bin/hcloud-csi-driver-node
14 changes: 12 additions & 2 deletions test/integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
FROM alpine:3.13

RUN apk add --no-cache ca-certificates e2fsprogs xfsprogs blkid xfsprogs-extra e2fsprogs-extra btrfs-progs cryptsetup
RUN apk add --no-cache coreutils
RUN apk add --no-cache \
blkid \
btrfs-progs \
ca-certificates \
cryptsetup \
e2fsprogs \
e2fsprogs-extra \
xfsprogs \
xfsprogs-extra

RUN apk add --no-cache \
coreutils

WORKDIR /test
COPY integration.tests /test/integration.tests
Expand Down

0 comments on commit 1785485

Please sign in to comment.