Browse Source

Add: docker build and push action

CareyWong 2 years ago
parent
commit
0fc330d2d1
2 changed files with 32 additions and 1 deletions
  1. 31 0
      .github/workflows/docker-build-push.yml
  2. 1 1
      Dockerfile

+ 31 - 0
.github/workflows/docker-build-push.yml

@@ -0,0 +1,31 @@
+name: Build and Push Multi-Arch Docker Image
+
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  build-and-push:
+    runs-on: ubuntu-latest
+
+    steps:
+    - name: Check out repository
+      uses: actions/checkout@master
+
+    - name: Set up Docker Buildx
+      uses: docker/setup-buildx-action@v2
+
+    - name: Log in to Docker Hub
+      uses: docker/login-action@v2
+      with:
+        username: ${{ secrets.DOCKERHUB_USERNAME }}
+        password: ${{ secrets.DOCKERHUB_PASSWORD }}
+
+    - name: Build and push Docker image
+      uses: docker/build-push-action@v3
+      with:
+        context: .
+        platforms: linux/amd64,linux/arm64
+        push: true
+        tags: careywong/subweb:latest

+ 1 - 1
Dockerfile

@@ -10,7 +10,7 @@ WORKDIR /app
 COPY . /app
 RUN yarn build
 
-FROM nginx:1.16-alpine
+FROM nginx:1.23-alpine
 COPY --from=build /app/dist /usr/share/nginx/html
 EXPOSE 80
 CMD [ "nginx", "-g", "daemon off;" ]