mirror of
https://github.com/stackbuilders/hapistrano.git
synced 2024-08-17 03:40:36 +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
76
.github/workflows/docker.yml
vendored
76
.github/workflows/docker.yml
vendored
@ -10,72 +10,66 @@ concurrency:
|
|||||||
group: docker-${{ github.ref }}
|
group: docker-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
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:
|
env:
|
||||||
if: contains(github.ref, 'refs/tags/v')
|
REGISTRY: ghcr.io
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [build]
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- name: Checkout
|
||||||
- uses: docker/setup-buildx-action@v1
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup Docker
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
restore-keys: ${{ runner.os }}-buildx-
|
restore-keys: ${{ runner.os }}-buildx-
|
||||||
path: /tmp/.buildx-cache
|
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:
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
registry: ${{ env.REGISTRY }}
|
- name: Generate metadata for Docker image
|
||||||
- uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ github.repository }}
|
||||||
id: meta
|
id: meta
|
||||||
- uses: docker/build-push-action@v2
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
push: true
|
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
- run: |
|
load: true
|
||||||
# this is a workaround, check the following issues:
|
- 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/docker/build-push-action/issues/252
|
||||||
# - https://github.com/moby/buildkit/issues/1896
|
# - https://github.com/moby/buildkit/issues/1896
|
||||||
|
- name: Move cache
|
||||||
|
run: |
|
||||||
rm -rf /tmp/.buildx-cache
|
rm -rf /tmp/.buildx-cache
|
||||||
mv /tmp/.buildx-cache-new /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
|
FROM utdemir/ghc-musl:v24-ghc902 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
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY hapistrano.cabal .
|
COPY hapistrano.cabal .
|
||||||
RUN cabal update && \
|
RUN cabal update && \
|
||||||
cabal configure -f static && \
|
cabal build --only-dependencies --enable-static
|
||||||
cabal build --only-dependencies
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cabal install
|
RUN cabal build --enable-executable-static && \
|
||||||
|
cp $(cabal exec which hap) hap
|
||||||
|
|
||||||
FROM alpine:3.15
|
FROM alpine:3.15
|
||||||
MAINTAINER Nicolas Vivar <nvivar@stackbuilders.com>
|
MAINTAINER Nicolas Vivar <nvivar@stackbuilders.com>
|
||||||
@ -29,5 +15,6 @@ RUN apk update && \
|
|||||||
git \
|
git \
|
||||||
openssh-client
|
openssh-client
|
||||||
RUN mkdir ~/.ssh
|
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"]
|
ENTRYPOINT ["/usr/local/bin/hap"]
|
||||||
|
CMD ["--help"]
|
||||||
|
Loading…
Reference in New Issue
Block a user