Merge pull request #48 from Promix953/main

优化Docker镜像构建
This commit is contained in:
johlanse 2022-08-07 21:37:25 +08:00 committed by GitHub
commit b7bd4d10b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 10 deletions

View File

@ -56,7 +56,7 @@ jobs:
with: with:
distribution: goreleaser distribution: goreleaser
version: latest version: latest
args: build --rm-dist ${{ steps.snapshot.outputs.ARG }} args: build --rm-dist --id docker ${{ steps.snapshot.outputs.ARG }}
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- -
@ -84,3 +84,6 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
shm-size: 2g

View File

@ -47,6 +47,20 @@ builds:
- -trimpath - -trimpath
ldflags: ldflags:
- -s -w -X main.VERSION=v{{.Version}} - -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: checksum:
name_template: "{{ .ProjectName }}_checksums.txt" name_template: "{{ .ProjectName }}_checksums.txt"
@ -87,3 +101,6 @@ nfpms:
- deb - deb
- rpm - rpm
maintainer: johlanse maintainer: johlanse
builds:
- nowin
- win

View File

@ -2,18 +2,23 @@ FROM debian:bullseye-slim
ARG TARGETARCH 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 && \
rm -rf /var/lib/apt/lists/* && \
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 COPY conf/config_default.yml /opt/config/config.yml
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ RUN chmod -R 777 /opt/study_xxqg && \
echo 'Asia/Shanghai' >/etc/timezone && apt-get -qq update \ cd /opt/ && \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl \ ./study_xxqg --init
&& 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
EXPOSE 8080 EXPOSE 8080
VOLUME /opt/config VOLUME /opt/config