diff --git a/.Dockerfile b/.Dockerfile new file mode 100644 index 0000000..90d08f5 --- /dev/null +++ b/.Dockerfile @@ -0,0 +1,29 @@ +FROM alpine AS build-env +COPY ./dist /dist +RUN arch="$(apk --print-arch)"; \ + case "$arch" in \ + 'x86_64') \ + export FOLDER='default_linux_amd64'; \ + ;; \ + 'armhf') \ + export FOLDER='default_linux_arm_6'; \ + ;; \ + 'armv7') \ + export FOLDER='default_linux_arm_7'; \ + ;; \ + 'aarch64') \ + export FOLDER='default_linux_arm64'; \ + ;; \ + 'x86') \ + export FOLDER='default_linux_386'; \ + ;; \ + *) echo >&2 "error: unsupported architecture '$arch'"; exit 1 ;; \ + esac \ + && mv /dist/$FOLDER /app ; \ + rm /dist -rf + +FROM alpine +RUN apk add --no-cache ca-certificates +COPY --from=build-env /app /app +WORKDIR /app +ENTRYPOINT ["./glider"] \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53229d3..f9cbfa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,15 @@ name: Build -on: [push, pull_request] +on: + push: + branches: + - 'dev' + tags: + - '*' + +env: + DOCKERHUB_REPO: nadoo/glider + GHCR_REPO: ghcr.io/nadoo/glider + PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 jobs: build: @@ -51,4 +61,44 @@ jobs: version: latest args: release --rm-dist env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker - Set up Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker - Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker - Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker - Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.DOCKERHUB_REPO }} + ${{ env.GHCR_REPO }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Docker - Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: .Dockerfile + platforms: ${{ env.PLATFORMS }} + push: true + tags: ${{ steps.meta.outputs.tags }} + \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 6402a16..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,67 +0,0 @@ -# https://github.com/docker/build-push-action#usage -name: Docker - -on: - push: - branches: - - 'dev' - tags: - - '*' - -env: - DOCKERHUB_REPO: nadoo/glider - GHCR_REPO: ghcr.io/nadoo/glider - PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 - -jobs: - publish: - name: Publish - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GHCR - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - images: | - ${{ env.DOCKERHUB_REPO }} - ${{ env.GHCR_REPO }} - tags: | - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - platforms: ${{ env.PLATFORMS }} - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max