-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor GitHub Actions draft workflow and Dockerfile to use upx to c…
…ompress binary (#247) * Refactor GitHub Actions draft workflow and Dockerfile to use upx to compress binary * Update missing logic to move file to gh actions runner
- Loading branch information
Showing
2 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
# Build | ||
FROM quay.io/benz0li/ghc-musl:9.6.6 AS build | ||
|
||
WORKDIR /usr/src/app | ||
COPY hapistrano.cabal . | ||
|
||
# Install upx | ||
RUN apk update && apk add --no-cache upx | ||
|
||
# Copy only the necessary files for dependency installation | ||
COPY hapistrano.cabal ./ | ||
|
||
# Install dependencies | ||
RUN cabal update && \ | ||
cabal build --only-dependencies --enable-static | ||
|
||
# Copy the rest of the files. | ||
COPY . . | ||
RUN cabal build --enable-executable-static && \ | ||
cp $(cabal exec which hap) hap | ||
|
||
# Build the application and compress the binary | ||
RUN cabal build --enable-executable-static && \ | ||
cp $(cabal exec which hap) hap && \ | ||
upx hap | ||
# Final image | ||
FROM alpine:3.15 | ||
MAINTAINER Cristhian Motoche <cmotoche@stackbuilders.com> | ||
|
||
LABEL maintainer="Cristhian Motoche <cmotoche@stackbuilders.com>" | ||
|
||
# Install runtime dependencies | ||
RUN apk update && \ | ||
apk add \ | ||
apk add --no-cache \ | ||
ca-certificates \ | ||
git \ | ||
openssh-client | ||
RUN mkdir ~/.ssh | ||
|
||
# Create .ssh directory | ||
RUN mkdir -p ~/.ssh | ||
|
||
# Copy the binary from the build stage | ||
COPY --from=build /usr/src/app/hap /usr/local/bin/hap | ||
|
||
# Set the entrypoint and default command | ||
ENTRYPOINT ["/usr/local/bin/hap"] | ||
CMD ["--help"] |