Files
swift-hpa/docker/Dockerfile
Michael Housh 15454e3686
All checks were successful
CI / Run Tests (push) Successful in 2m33s
Build docker images / docker (push) Successful in 6m49s
feat: Adds entrypoint.sh script to docker to allow attaching to a shell inside the container.
2025-11-07 13:18:57 -05:00

74 lines
1.9 KiB
Docker
Executable File

# Used this to build the release version of the image.
# Build the executable
ARG SWIFT_IMAGE_VERSION="6.0.3"
# ============================================================
# Build Swift Image
# ============================================================
FROM docker.io/swift:${SWIFT_IMAGE_VERSION} AS build
# Install OS updates
RUN export DEBIAN_FRONTEND=nointeractive DEBCONF_NOINTERACTIVE_SEEN=true && \
apt-get -q update && \
apt-get -q dist-upgrade -y && \
apt-get install -y libjemalloc-dev
WORKDIR /build
# Resolve dependencies, this creates a cached layer.
COPY ./Package.* ./
RUN --mount=type=cache,target=/build/.build swift package resolve
COPY . .
# Build the application.
RUN --mount=type=cache,target=/build/.build \
swift build -c release \
--product hpa \
--static-swift-stdlib \
-Xlinker -ljemalloc
# Switch to staging area.
WORKDIR /staging
# Copy main executable to staging area.
RUN --mount=type=cache,target=/build/.build \
cp "$(swift build --package-path /build -c release --show-bin-path)/hpa" ./
# ============================================================
# Run Image
# ============================================================
FROM docker.io/ubuntu:noble
RUN export DEBIAN_FRONTEND=nointeractive DEBCONF_NOINTERACTIVE_SEEN=true && \
apt-get -q update && \
apt-get -q dist-upgrade -y && \
apt-get -q install -y \
ansible \
curl \
imagemagick \
pandoc \
texlive \
libjemalloc2 \
libcurl4 \
tzdata \
&& rm -r /var/lib/apt/lists/*
COPY --from=build /staging/hpa /usr/local/bin
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Setup volumes
RUN mkdir /config && \
mkdir /consults && \
mkdir /playbook && \
mkdir /template && \
mkdir -p /root/.local/share/hpa && \
ln -sfv /config /root/.config && \
ln -sfv /playbook /root/.local/share/hpa/playbook
VOLUME /config /consults /playbook /template
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["--help"]