Repository navigation
Expand file tree
/
Copy pathDockerfile.template
More file actions
52 lines (34 loc) · 1.57 KB
/
Copy pathDockerfile.template
File metadata and controls
52 lines (34 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM swift:6.3-noble AS build
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get install -y libjemalloc-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY ./Package.* ./
RUN swift package resolve
COPY . .
ARG CRANECTL_VERSION
RUN test -n "$CRANECTL_VERSION" \
&& sed -i 's|cranectlVersion: String? = nil|cranectlVersion: String? = "'"$CRANECTL_VERSION"'"|' \
Sources/CraneCTL/Version.swift
RUN swift build -c release --product cranectl --static-swift-stdlib -Xlinker -ljemalloc
WORKDIR /staging
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/cranectl" ./
RUN cp "/usr/libexec/swift/linux/swift-backtrace-static" ./
FROM ubuntu:noble
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get -q install -y libjemalloc2 \
&& rm -r /var/lib/apt/lists/*
RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app cranectl
WORKDIR /app
COPY --from=build --chown=cranectl:cranectl /staging /app
ENV SWIFT_BACKTRACE=enable=yes,sanitize=yes,threads=all,images=all,interactive=no,swift-backtrace=./swift-backtrace-static
USER cranectl:cranectl
LABEL org.opencontainers.image.source="https://github.com/cranesql/cranectl"
LABEL org.opencontainers.image.description="A CLI for Crane, the lightweight migration tool for SQL databases."
LABEL org.opencontainers.image.licenses="Apache-2.0"
ENTRYPOINT [ "./cranectl" ]
CMD [ "--help" ]