Skip to content

Commit

Permalink
feat(docker): added base dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur-akamai committed Nov 22, 2023
1 parent 7b34cad commit 6b6cbd5
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Binaries for programs and plugins
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Go workspace file
go.work

# Helm resources
helm/
70 changes: 70 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2023 Linode, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG TOOLCHAIN_VERSION=1.21

#########################################################################################
# Build
#########################################################################################

# First stage: building the driver executable.
FROM docker.io/library/golang:${TOOLCHAIN_VERSION} as builder

WORKDIR /work

# Copy the Go Modules manifests.
COPY go.mod go.mod
COPY go.sum go.sum

# Cache dep before building and copying source so that we don't need to re-download as
# much and so that source changes don't invalidate our downloaded layer.
RUN go mod download

# Copy the go source.
COPY cmd/ cmd/
COPY internal/ internal/
COPY pkg/ pkg/
COPY Makefile Makefile

# Explicitly set the version, so the make won't try to get it (and fail).
ENV VERSION="builder"

# Build.
RUN make build

#########################################################################################
# Runtime
#########################################################################################

# Second stage: building final environment for running the executable.
FROM gcr.io/distroless/static-debian11:latest AS runtime

COPY --from=builder /work/bin/linode-cosi-driver /usr/bin/linode-cosi-driver

# Set volume mount point for app socket.
VOLUME [ "/var/lib/cosi" ]

# Disable healthcheck.
HEALTHCHECK NONE

# Add labels
LABEL name="linode-cosi-driver"
LABEL description="COSI Driver for Linode Object Storage"
LABEL vendor="Linode, LLC"
LABEL license="Apache-2.0"
LABEL maintainers="Linode COSI Driver Authors"

# Set the entrypoint.
ENTRYPOINT [ "/usr/bin/linode-cosi-driver" ]
CMD []

0 comments on commit 6b6cbd5

Please sign in to comment.