mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
Optimize build time
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/.idea
|
/.idea
|
||||||
/*.iml
|
/*.iml
|
||||||
|
|
||||||
/.dev
|
.dev
|
||||||
/.git
|
/.git
|
||||||
/.github
|
/.github
|
||||||
/.res
|
/.res
|
||||||
|
|||||||
24
.github/workflows/build.yml
vendored
24
.github/workflows/build.yml
vendored
@@ -4,7 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'v*'
|
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
@@ -15,7 +14,6 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'v*'
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- '.github/workflows/docs.yml'
|
- '.github/workflows/docs.yml'
|
||||||
@@ -55,17 +53,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --skip-publish --rm-dist
|
args: release --skip-publish --rm-dist
|
||||||
-
|
|
||||||
name: Test
|
|
||||||
run: |
|
|
||||||
go test -coverprofile=coverage.txt -covermode=atomic -race ./...
|
|
||||||
-
|
|
||||||
name: Upload coverage
|
|
||||||
uses: codecov/codecov-action@v1
|
|
||||||
if: success()
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
file: ./coverage.txt
|
|
||||||
-
|
-
|
||||||
name: GitHub Release
|
name: GitHub Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
@@ -82,7 +69,6 @@ jobs:
|
|||||||
|
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: go
|
|
||||||
env:
|
env:
|
||||||
DOCKERHUB_SLUG: crazymax/diun
|
DOCKERHUB_SLUG: crazymax/diun
|
||||||
GHCR_SLUG: ghcr.io/crazy-max/diun
|
GHCR_SLUG: ghcr.io/crazy-max/diun
|
||||||
@@ -109,6 +95,14 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: "--debug"
|
buildkitd-flags: "--debug"
|
||||||
|
-
|
||||||
|
name: Cache Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@@ -140,6 +134,8 @@ jobs:
|
|||||||
org.opencontainers.image.title=Diun
|
org.opencontainers.image.title=Diun
|
||||||
org.opencontainers.image.description=Docker image update notifier
|
org.opencontainers.image.description=Docker image update notifier
|
||||||
org.opencontainers.image.vendor=CrazyMax
|
org.opencontainers.image.vendor=CrazyMax
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
|
||||||
-
|
-
|
||||||
name: Check manifest
|
name: Check manifest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
|
|||||||
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@@ -4,7 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'v*'
|
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
paths:
|
paths:
|
||||||
@@ -15,7 +14,6 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'v*'
|
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/docs.yml'
|
- '.github/workflows/docs.yml'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
|||||||
57
.github/workflows/test.yml
vendored
Normal file
57
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
name: test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- '.github/workflows/docs.yml'
|
||||||
|
- 'docs/**'
|
||||||
|
- 'mkdocs.yml'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- '.github/workflows/docs.yml'
|
||||||
|
- 'docs/**'
|
||||||
|
- 'mkdocs.yml'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.13
|
||||||
|
-
|
||||||
|
name: Cache Go modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
-
|
||||||
|
name: Go mod
|
||||||
|
run: |
|
||||||
|
go mod download
|
||||||
|
-
|
||||||
|
name: Test
|
||||||
|
run: |
|
||||||
|
go test -coverprofile=coverage.txt -covermode=atomic -race ./...
|
||||||
|
-
|
||||||
|
name: Upload coverage
|
||||||
|
uses: codecov/codecov-action@v1
|
||||||
|
if: success()
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
file: ./coverage.txt
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,5 +4,3 @@
|
|||||||
.dev
|
.dev
|
||||||
/bin
|
/bin
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
/site
|
|
||||||
|
|||||||
34
Dockerfile
34
Dockerfile
@@ -1,29 +1,25 @@
|
|||||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} tonistiigi/xx:golang AS xgo
|
ARG GO_VERSION=1.13
|
||||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13-alpine AS builder
|
|
||||||
|
|
||||||
ARG VERSION=dev
|
ARG VERSION=dev
|
||||||
|
|
||||||
ENV CGO_ENABLED 0
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} tonistiigi/xx:golang AS xgo
|
||||||
ENV GO111MODULE on
|
|
||||||
ENV GOPROXY https://goproxy.io,direct
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:${GO_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache curl gcc git musl-dev
|
||||||
COPY --from=xgo / /
|
COPY --from=xgo / /
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
RUN apk --update --no-cache add \
|
FROM base AS gomod
|
||||||
build-base \
|
COPY . .
|
||||||
gcc \
|
|
||||||
git \
|
|
||||||
&& rm -rf /tmp/* /var/cache/apk/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY . ./
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
|
FROM gomod AS build
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
RUN go env
|
ARG VERSION
|
||||||
RUN go build -ldflags "-w -s -X 'main.version=${VERSION}'" -v -o diun cmd/main.go
|
ENV CGO_ENABLED 0
|
||||||
|
ENV GOPROXY https://goproxy.io,direct
|
||||||
|
RUN go build -ldflags "-w -s -X 'main.version=${VERSION}'" -v -o /opt/diun cmd/main.go
|
||||||
|
|
||||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:latest
|
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:latest
|
||||||
LABEL maintainer="CrazyMax"
|
LABEL maintainer="CrazyMax"
|
||||||
@@ -33,8 +29,8 @@ RUN apk --update --no-cache add \
|
|||||||
libressl \
|
libressl \
|
||||||
&& rm -rf /tmp/* /var/cache/apk/*
|
&& rm -rf /tmp/* /var/cache/apk/*
|
||||||
|
|
||||||
COPY --from=builder /app/diun /usr/local/bin/diun
|
COPY --from=build /opt/diun /usr/local/bin/diun
|
||||||
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
|
COPY --from=build /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
|
||||||
RUN diun --version
|
RUN diun --version
|
||||||
|
|
||||||
ENV DIUN_DB_PATH="/data/diun.db"
|
ENV DIUN_DB_PATH="/data/diun.db"
|
||||||
|
|||||||
Reference in New Issue
Block a user