Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Builder stage
FROM rust:1-slim-bookworm AS builder

# Labels for the builder stage
LABEL stage=builder

# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libclang-dev \
perl \
pkg-config \
make \
&& rm -rf /var/lib/apt/lists/*

# Create a new empty shell project
WORKDIR /usr/src/squawk

# First, copy only the workspace configuration and toolchain files
COPY Cargo.toml Cargo.lock rust-toolchain.toml ./

# Copy the entire project
COPY . .

# Build the release version
RUN cargo build --release

# Final stage
FROM debian:bookworm-slim

# Metadata labels
LABEL org.opencontainers.image.title="Squawk"
LABEL org.opencontainers.image.description="Linter for PostgreSQL focused on database migrations"
LABEL org.opencontainers.image.licenses="GPL-3.0"
LABEL org.opencontainers.image.source="https://github.com/sbdchd/squawk"

# Create a non-root user to run the application
RUN groupadd -r squawk && useradd -r -g squawk squawk

# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy the binary from the builder stage
COPY --from=builder /usr/src/squawk/target/release/squawk /usr/local/bin/squawk

# Set the ownership of the binary
RUN chown squawk:squawk /usr/local/bin/squawk

# Switch to non-root user
USER squawk

WORKDIR /data

# Command to run when the container starts
ENTRYPOINT ["squawk"]
CMD ["--help"]
Loading