update dockerfile: add multi-arch and multi-stage

This commit is contained in:
BaoXuebin 2022-01-18 23:25:51 +08:00
parent cab39eabb6
commit d9cb8486b1
2 changed files with 25 additions and 9 deletions

View File

@ -7,15 +7,26 @@ jobs:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
-
name: Check out the repo
uses: actions/checkout@v2
- name: Log in to Docker Hub
-
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
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: xdbin/beancount-gs:latest

View File

@ -1,18 +1,23 @@
# syntax=docker/dockerfile:1
FROM golang:1.17.3
FROM golang:1.17.3 AS builder
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct \
GIN_MODE=release \
PORT=80
# install beancount
RUN apt-get update || : && apt-get install python3.5 python3-pip -y
RUN pip3 install beancount -i https://pypi.tuna.tsinghua.edu.cn/simple
WORKDIR /app
WORKDIR /builder
COPY . .
COPY public/icons ./public/default_icons
RUN go build .
FROM python:latest
RUN pip3 install beancount -i https://pypi.tuna.tsinghua.edu.cn/simple
WORKDIR /app
COPY --from=builder ./builder/public ./public
COPY --from=builder ./builder/config ./config
COPY --from=builder ./builder/template ./template
COPY --from=builder ./builder/beancount-gs* ./
EXPOSE 80