feat: Updates Dockerfile, WIP
This commit is contained in:
@@ -2,23 +2,74 @@
|
|||||||
# Build the executable
|
# Build the executable
|
||||||
ARG SWIFT_IMAGE_VERSION="6.0.3"
|
ARG SWIFT_IMAGE_VERSION="6.0.3"
|
||||||
|
|
||||||
FROM swift:${SWIFT_IMAGE_VERSION} AS build
|
# ============================================================
|
||||||
|
# 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
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Resolve dependencies, this creates a cached layer.
|
||||||
COPY ./Package.* ./
|
COPY ./Package.* ./
|
||||||
RUN swift package resolve
|
RUN --mount=type=cache,target=/build/.build swift package resolve
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN swift build -c release -Xswiftc -g
|
|
||||||
|
|
||||||
# Run image
|
# Build the application.
|
||||||
FROM swift:${SWIFT_IMAGE_VERSION}-slim
|
RUN --mount=type=cache,target=/build/.build \
|
||||||
|
swift build -c release \
|
||||||
|
--product hpa \
|
||||||
|
--static-swift-stdlib \
|
||||||
|
-Xlinker -ljemalloc
|
||||||
|
|
||||||
RUN export DEBIAN_FRONTEND=nointeractive DEBCONF_NOINTERACTIVE_SEEN=true && apt-get -q update && \
|
# 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 \
|
apt-get -q install -y \
|
||||||
ansible \
|
ansible \
|
||||||
curl \
|
curl \
|
||||||
|
imagemagick \
|
||||||
pandoc \
|
pandoc \
|
||||||
texlive \
|
texlive \
|
||||||
|
libjemalloc2 \
|
||||||
|
libcurl4 \
|
||||||
|
tzdata \
|
||||||
&& rm -r /var/lib/apt/lists/*
|
&& rm -r /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY --from=build /build/.build/release/hpa /usr/local/bin
|
COPY --from=build /staging/hpa /usr/local/bin
|
||||||
|
|
||||||
|
# Setup completion
|
||||||
|
RUN mkdir /root/.bash_completion && \
|
||||||
|
echo "source /root/.bash_completion/hpa.bash" >>/root/.bashrc && \
|
||||||
|
/usr/local/bin/hpa --generate-completion-script bash >/root/.bash_completion/hpa.bash
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
CMD ["/bin/bash", "-xc", "/usr/local/bin/hpa"]
|
CMD ["/bin/bash", "-xc", "/usr/local/bin/hpa"]
|
||||||
|
|||||||
Reference in New Issue
Block a user