From 1d5dc29d066753ec84170a98bb6f1cd55f63bd0e Mon Sep 17 00:00:00 2001 From: Promix953 Date: Sun, 7 Aug 2022 20:41:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96Docker=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/push-to-docker.yml | 5 ++++- .goreleaser.yml | 19 ++++++++++++++++++- Dockerfile | 20 ++++++++++++-------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/push-to-docker.yml b/.github/workflows/push-to-docker.yml index 27dc502..65b3496 100644 --- a/.github/workflows/push-to-docker.yml +++ b/.github/workflows/push-to-docker.yml @@ -56,7 +56,7 @@ jobs: with: distribution: goreleaser version: latest - args: build --rm-dist ${{ steps.snapshot.outputs.ARG }} + args: build --rm-dist --id docker ${{ steps.snapshot.outputs.ARG }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - @@ -84,3 +84,6 @@ jobs: push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + shm-size: 2g diff --git a/.goreleaser.yml b/.goreleaser.yml index 6a8ab1e..f6d578d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -47,6 +47,20 @@ builds: - -trimpath ldflags: - -s -w -X main.VERSION=v{{.Version}} + - id: docker + env: + - CGO_ENABLED=0 + - GO111MODULE=on + goos: + - linux + goarch: + - amd64 + - arm64 + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - -s -w -X main.VERSION=v{{.Version}} checksum: name_template: "{{ .ProjectName }}_checksums.txt" @@ -86,4 +100,7 @@ nfpms: formats: - deb - rpm - maintainer: johlanse \ No newline at end of file + maintainer: johlanse + builds: + - nowin + - win \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b36aa5c..dac0132 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,22 @@ FROM debian:bullseye-slim ARG TARGETARCH -COPY ./dist/nowin_linux_$TARGETARCH*/study_xxqg /opt/study_xxqg +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + echo 'Asia/Shanghai' >/etc/timezone && \ + apt-get -qq update && \ + apt-get -qq install -y --no-install-recommends ca-certificates curl && \ + apt-get install -y libx11-6 libgbm1 libasound2 libcairo2 libxshmfence1 libatspi2.0-0 libpango-1.0-0 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxrandr2 libxfixes3 libxdamage1 libxcomposite1 libxkbcommon0 && \ + apt-get clean && \ + mkdir /opt/config/ -RUN mkdir /opt/config/ +COPY ./dist/docker_linux_$TARGETARCH*/study_xxqg /opt/study_xxqg COPY conf/config_default.yml /opt/config/config.yml -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ - echo 'Asia/Shanghai' >/etc/timezone && apt-get -qq update \ - && apt-get -qq install -y --no-install-recommends ca-certificates curl \ - && apt-get update && apt-get install -y libx11-6 libgbm1 libasound2 libcairo2 libxshmfence1 libatspi2.0-0 libpango-1.0-0 libnss3 \ - libatk1.0-0 libatk-bridge2.0-0 libcups2 libxrandr2 libxfixes3 libxdamage1 libxcomposite1 libxkbcommon0 \ - && chmod -R 777 /opt/study_xxqg && cd /opt/ && ./study_xxqg --init +RUN chmod -R 777 /opt/study_xxqg && \ + cd /opt/ && \ + ./study_xxqg --init + EXPOSE 8080 VOLUME /opt/config From 8d78aed6daa0efd2927bc476403da7d4f39bc1cc Mon Sep 17 00:00:00 2001 From: Promix953 Date: Sun, 7 Aug 2022 21:17:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BC=A9=E5=87=8FDocker=E4=BD=93=E7=A7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index dac0132..5f5aa26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ apt-get -qq install -y --no-install-recommends ca-certificates curl && \ apt-get install -y libx11-6 libgbm1 libasound2 libcairo2 libxshmfence1 libatspi2.0-0 libpango-1.0-0 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxrandr2 libxfixes3 libxdamage1 libxcomposite1 libxkbcommon0 && \ apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ mkdir /opt/config/ COPY ./dist/docker_linux_$TARGETARCH*/study_xxqg /opt/study_xxqg