Skip to content

Commit

Permalink
docker ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tianze0926 committed Jul 25, 2022
1 parent 59d0787 commit 8b17ec6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI to Docker Hub

on:
push:
tags:
- "**"

jobs:

docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v2 # for multi-architecture builds
- id: buidlx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/qzyq-water-sub:${{ github.ref_name }}
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# syntax=docker/dockerfile:1

FROM node:lts-alpine as frontend_builder
WORKDIR /app
COPY frontend/ .
RUN npm install
RUN npm run build

FROM golang:1.16-alpine as backend_builder
COPY . .
COPY --from=frontend_builder /app/build ./frontend/
RUN go mod download
RUN go build -o /app

FROM alpine:latest
COPY --from=backend_builder /app /app
EXPOSE 8080
CMD /app -addr 0.0.0.0 -port 8080

0 comments on commit 8b17ec6

Please sign in to comment.