mirror of
https://github.com/stackbuilders/hapistrano.git
synced 2024-07-14 19:10:34 +03:00
Co-authored-by: Cristhian Motoche <cmotoche@stackbuilders.com> Co-authored-by: David Mazarro <dmunuera@stackbuilders.com>
This commit is contained in:
parent
00f285010b
commit
0e4bef339b
80
.github/workflows/docker.yml
vendored
80
.github/workflows/docker.yml
vendored
@ -10,72 +10,66 @@ concurrency:
|
||||
group: docker-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: ${{ runner.os }}-buildx-
|
||||
path: /tmp/.buildx-cache
|
||||
- uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
tags: ${{ env.IMAGE_NAME }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||
load: true
|
||||
- run: docker run ${{ env.IMAGE_NAME }} --version
|
||||
- run: |
|
||||
# this is a workaround, check the following issues:
|
||||
# - https://github.com/docker/build-push-action/issues/252
|
||||
# - https://github.com/moby/buildkit/issues/1896
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
publish:
|
||||
if: contains(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Docker
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: ${{ runner.os }}-buildx-
|
||||
path: /tmp/.buildx-cache
|
||||
- uses: docker/login-action@v1
|
||||
- name: Login to GH container registry
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: ${{ env.REGISTRY }}
|
||||
- uses: docker/metadata-action@v3
|
||||
- name: Generate metadata for Docker image
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
images: ${{ env.REGISTRY }}/${{ github.repository }}
|
||||
id: meta
|
||||
- uses: docker/build-push-action@v2
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||
push: true
|
||||
- run: |
|
||||
# this is a workaround, check the following issues:
|
||||
# - https://github.com/docker/build-push-action/issues/252
|
||||
# - https://github.com/moby/buildkit/issues/1896
|
||||
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
load: true
|
||||
- name: Smoke test
|
||||
run: docker run ${{ steps.meta.outputs.tags }} --version
|
||||
- name: Copy static binary from Docker to the host
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: docker run -v $PWD/bin:/root/bin --entrypoint cp ${{ steps.meta.outputs.tags }} /usr/local/bin/hap /root/bin/hap-${{ github.ref_name }}-linux-x86_64-bin
|
||||
- name: Create GH release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
bin/hap-*
|
||||
LICENSE
|
||||
draft: true
|
||||
# Temp fix:
|
||||
# - https://github.com/docker/build-push-action/issues/252
|
||||
# - https://github.com/moby/buildkit/issues/1896
|
||||
- name: Move cache
|
||||
run: |
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
25
Dockerfile
25
Dockerfile
@ -1,25 +1,11 @@
|
||||
FROM alpine:3.15 AS build
|
||||
RUN apk update && \
|
||||
apk add \
|
||||
alpine-sdk \
|
||||
bash \
|
||||
ca-certificates \
|
||||
cabal \
|
||||
ghc \
|
||||
ghc-dev \
|
||||
git \
|
||||
gmp-dev \
|
||||
gnupg \
|
||||
libffi-dev \
|
||||
linux-headers \
|
||||
zlib-dev
|
||||
FROM utdemir/ghc-musl:v24-ghc902 AS build
|
||||
WORKDIR /usr/src/app
|
||||
COPY hapistrano.cabal .
|
||||
RUN cabal update && \
|
||||
cabal configure -f static && \
|
||||
cabal build --only-dependencies
|
||||
cabal build --only-dependencies --enable-static
|
||||
COPY . .
|
||||
RUN cabal install
|
||||
RUN cabal build --enable-executable-static && \
|
||||
cp $(cabal exec which hap) hap
|
||||
|
||||
FROM alpine:3.15
|
||||
MAINTAINER Nicolas Vivar <nvivar@stackbuilders.com>
|
||||
@ -29,5 +15,6 @@ RUN apk update && \
|
||||
git \
|
||||
openssh-client
|
||||
RUN mkdir ~/.ssh
|
||||
COPY --from=build /root/.cabal/bin/hap /usr/local/bin/hap
|
||||
COPY --from=build /usr/src/app/hap /usr/local/bin/hap
|
||||
ENTRYPOINT ["/usr/local/bin/hap"]
|
||||
CMD ["--help"]
|
||||
|
Loading…
Reference in New Issue
Block a user