mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
🎉 reduce docker image build time
Merge pull request #238 from naiba/dev
This commit is contained in:
commit
f9f0857eb6
35
.github/workflows/dashboard.yml
vendored
35
.github/workflows/dashboard.yml
vendored
@ -15,6 +15,35 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Extract branch name
|
||||
run: |
|
||||
export BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
|
||||
echo "##[set-output name=branch;]$BRANCH_NAME"
|
||||
if [ $BRANCH_NAME = "main" ] || [ $BRANCH_NAME = "master" ]
|
||||
then echo "##[set-output name=tag;]latest"
|
||||
else echo "##[set-output name=tag;]$BRANCH_NAME"
|
||||
fi
|
||||
id: extract_branch
|
||||
|
||||
- name: xgo build
|
||||
uses: crazy-max/ghaction-xgo@v2
|
||||
with:
|
||||
xgo_version: latest
|
||||
go_version: 1.18
|
||||
dest: dist
|
||||
pkg: cmd/dashboard
|
||||
prefix: dashboard
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386,
|
||||
v: true
|
||||
x: false
|
||||
race: false
|
||||
ldflags: -s -w
|
||||
buildmode: default
|
||||
|
||||
- name: fix dist
|
||||
run: |
|
||||
cp dist/dashboard-linux-arm-7 dist/dashboard-linux-arm
|
||||
|
||||
- name: Log in to the GHCR
|
||||
uses: docker/login-action@master
|
||||
with:
|
||||
@ -51,8 +80,8 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/arm,linux/386,linux/s390x
|
||||
platforms: linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/riscv64 # linux/386,
|
||||
push: true
|
||||
tags: |
|
||||
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}
|
||||
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}
|
||||
${{ steps.image-name.outputs.GHRC_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
||||
${{ steps.image-name.outputs.ALI_IMAGE_NAME }}:${{ steps.extract_branch.outputs.tag }}
|
||||
|
26
Dockerfile
26
Dockerfile
@ -1,22 +1,22 @@
|
||||
FROM golang:alpine AS binarybuilder
|
||||
RUN apk --no-cache --no-progress add \
|
||||
gcc git musl-dev
|
||||
WORKDIR /dashboard
|
||||
COPY . .
|
||||
RUN cd cmd/dashboard && go build -o app -ldflags="-s -w"
|
||||
FROM ubuntu:focal
|
||||
|
||||
FROM alpine:latest
|
||||
ENV TZ="Asia/Shanghai"
|
||||
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
COPY ./script/entrypoint.sh /entrypoint.sh
|
||||
RUN apk --no-cache --no-progress add \
|
||||
ca-certificates \
|
||||
tzdata && \
|
||||
cp "/usr/share/zoneinfo/$TZ" /etc/localtime && \
|
||||
echo "$TZ" > /etc/timezone && \
|
||||
|
||||
RUN export DEBIAN_FRONTEND="noninteractive" && \
|
||||
apt update && apt install -y ca-certificates tzdata && \
|
||||
update-ca-certificates && \
|
||||
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
|
||||
dpkg-reconfigure tzdata && \
|
||||
chmod +x /entrypoint.sh
|
||||
|
||||
WORKDIR /dashboard
|
||||
COPY ./resource ./resource
|
||||
COPY --from=binarybuilder /dashboard/cmd/dashboard/app ./app
|
||||
COPY dist/dashboard-${TARGETOS}-${TARGETARCH} ./app
|
||||
|
||||
VOLUME ["/dashboard/data"]
|
||||
EXPOSE 80 5555
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
echo -e "nameserver 127.0.0.11\nnameserver 8.8.8.8\nnameserver 223.5.5.5\n" > /etc/resolv.conf
|
||||
echo -e "nameserver 127.0.0.11\nnameserver 8.8.4.4\nnameserver 223.5.5.5\n" > /etc/resolv.conf
|
||||
/dashboard/app
|
Loading…
Reference in New Issue
Block a user