Skip to content
Snippets Groups Projects
Containerfile 834 B
# Use an official Golang image as a build stage
FROM golang:1.22 AS builder

# Set the Current Working Directory inside the container
WORKDIR /app

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

# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download

# Copy the source from the current directory to the Working Directory inside the container
COPY . .

# Build the Go app for Linux
RUN GOOS=linux GOARCH=amd64 go build -o ds

# Use an official Debian image as the base image
FROM debian:latest

# Install dependencies
RUN apt-get update && apt-get upgrade

# Set the Current Working Directory inside the container
WORKDIR /app

# Copy the built binary from the builder stage
COPY --from=builder /app/ds /usr/local/bin/ds

# Default command
CMD ["ds"]