Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit e5b2501

Browse files
authored
Improve docker building (#14)
- Add support for arm64 - Build Docker images with buildx - Replace CR_PAT with GITHUB_TOKEN - Trigger build on push or pull request events
1 parent a50214c commit e5b2501

File tree

3 files changed

+39
-32
lines changed

3 files changed

+39
-32
lines changed

.github/workflows/build.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on: [push, pull_request]
2+
3+
env:
4+
IMAGE_NAME: restbase
5+
6+
jobs:
7+
docker_image_job:
8+
runs-on: ubuntu-latest
9+
steps:
10+
# don't need to use the actions/checkout when using setup-buildx-action
11+
12+
- name: Set up QEMU
13+
uses: docker/setup-qemu-action@v1
14+
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v1
17+
18+
- name: Login to GitHub Container Registry
19+
if: github.repository_owner == 'femiwiki'
20+
uses: docker/login-action@v1
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.repository_owner }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- id: version
27+
run: echo "::set-output name=version::$(date +%Y-%m-%dT%H-%M)-$(echo ${{ github.sha }} | cut -c1-8)"
28+
29+
- name: Build and push
30+
id: docker_build
31+
uses: docker/build-push-action@v2
32+
with:
33+
cache-from: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
34+
platforms: linux/amd64,linux/arm64
35+
push: ${{ github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main' }}
36+
tags: |
37+
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
38+
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest

.github/workflows/main.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:10-alpine
1+
FROM --platform=$TARGETPLATFORM node:10-alpine
22

33
ARG NODE_ENV=production
44
# Environment variables used by RESTBase

0 commit comments

Comments
 (0)