2024-10-18 21:32:03 +03:00
|
|
|
# Build
|
2024-10-01 18:14:44 +03:00
|
|
|
FROM quay.io/benz0li/ghc-musl:9.6.6 AS build
|
2024-10-18 21:32:03 +03:00
|
|
|
|
2022-04-01 21:45:11 +03:00
|
|
|
WORKDIR /usr/src/app
|
2024-10-18 21:32:03 +03:00
|
|
|
|
|
|
|
# Install upx
|
|
|
|
RUN apk update && apk add --no-cache upx
|
|
|
|
|
|
|
|
# Copy only the necessary files for dependency installation
|
|
|
|
COPY hapistrano.cabal ./
|
|
|
|
|
|
|
|
# Install dependencies
|
2022-04-01 21:45:11 +03:00
|
|
|
RUN cabal update && \
|
2022-05-12 00:30:50 +03:00
|
|
|
cabal build --only-dependencies --enable-static
|
2024-10-18 21:32:03 +03:00
|
|
|
|
|
|
|
# Copy the rest of the files.
|
2022-04-01 21:45:11 +03:00
|
|
|
COPY . .
|
2018-05-14 16:23:06 +03:00
|
|
|
|
2024-10-18 21:32:03 +03:00
|
|
|
# Build the application and compress the binary
|
|
|
|
RUN cabal build --enable-executable-static && \
|
|
|
|
cp $(cabal exec which hap) hap && \
|
|
|
|
upx hap
|
|
|
|
# Final image
|
2022-04-01 21:45:11 +03:00
|
|
|
FROM alpine:3.15
|
2024-10-18 21:32:03 +03:00
|
|
|
|
|
|
|
LABEL maintainer="Cristhian Motoche <cmotoche@stackbuilders.com>"
|
|
|
|
|
|
|
|
# Install runtime dependencies
|
2022-04-01 21:45:11 +03:00
|
|
|
RUN apk update && \
|
2024-10-18 21:32:03 +03:00
|
|
|
apk add --no-cache \
|
2022-04-01 21:45:11 +03:00
|
|
|
ca-certificates \
|
|
|
|
git \
|
|
|
|
openssh-client
|
2024-10-18 21:32:03 +03:00
|
|
|
|
|
|
|
# Create .ssh directory
|
|
|
|
RUN mkdir -p ~/.ssh
|
|
|
|
|
|
|
|
# Copy the binary from the build stage
|
2022-05-12 00:30:50 +03:00
|
|
|
COPY --from=build /usr/src/app/hap /usr/local/bin/hap
|
2024-10-18 21:32:03 +03:00
|
|
|
|
|
|
|
# Set the entrypoint and default command
|
2022-04-01 21:45:11 +03:00
|
|
|
ENTRYPOINT ["/usr/local/bin/hap"]
|
2022-05-12 00:30:50 +03:00
|
|
|
CMD ["--help"]
|