mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-26 01:52:42 +00:00
ci: refactor dockerfile to build with many speed
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -17,7 +17,38 @@ permissions:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
buildx-bake:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
with:
|
||||||
|
fetch-tags: true
|
||||||
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
|
||||||
|
|
||||||
|
- name: Log into registry
|
||||||
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: build
|
||||||
|
uses: docker/bake-action@76f9fa3a758507623da19f6092dc4089a7e61592 # v6.6.0
|
||||||
|
with:
|
||||||
|
source: .
|
||||||
|
push: true
|
||||||
|
sbom: true
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
set: ""
|
||||||
|
|
||||||
|
containerbuild:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
+10
-6
@@ -1,5 +1,6 @@
|
|||||||
variable "ALPINE_VERSION" { default = "3.22" }
|
variable "ALPINE_VERSION" { default = "3.22" }
|
||||||
variable "GITHUB_SHA" { default = "devel" }
|
variable "GITHUB_SHA" { default = "devel" }
|
||||||
|
variable "VERSION" { default = "devel-docker" }
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = [
|
targets = [
|
||||||
@@ -10,19 +11,22 @@ group "default" {
|
|||||||
target "osiris" {
|
target "osiris" {
|
||||||
args = {
|
args = {
|
||||||
ALPINE_VERSION = "3.22"
|
ALPINE_VERSION = "3.22"
|
||||||
|
VERSION = "${VERSION}"
|
||||||
}
|
}
|
||||||
context = "."
|
context = "."
|
||||||
dockerfile = "./docker/osiris.Dockerfile"
|
dockerfile = "./docker/osiris.Dockerfile"
|
||||||
platforms = [
|
platforms = [
|
||||||
"linux/amd64",
|
"linux/amd64",
|
||||||
# "linux/arm64",
|
"linux/arm64",
|
||||||
# "linux/arm/v7",
|
"linux/arm/v7",
|
||||||
# "linux/ppc64le",
|
"linux/ppc64le",
|
||||||
# "linux/riscv64",
|
"linux/riscv64",
|
||||||
]
|
]
|
||||||
pull = true
|
pull = true
|
||||||
|
sbom = true
|
||||||
|
provenance = true
|
||||||
tags = [
|
tags = [
|
||||||
"ghcr.io/techarohq/anubis/osiris:${GITHUB_SHA}",
|
"ghcr.io/techarohq/anubis/osiris:${VERSION}",
|
||||||
"ghcr.io/techarohq/anubis/osiris:main"
|
"ghcr.io/techarohq/anubis/osiris:main"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,22 @@
|
|||||||
ARG ALPINE_VERSION=edge
|
ARG ALPINE_VERSION=edge
|
||||||
FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS build
|
FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS build
|
||||||
|
|
||||||
ARG TARGETOS
|
|
||||||
ARG TARGETARCH
|
|
||||||
ARG VERSION=devel-docker
|
|
||||||
|
|
||||||
RUN apk -U add go nodejs git build-base git npm bash zstd brotli gzip
|
RUN apk -U add go nodejs git build-base git npm bash zstd brotli gzip
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/root/go go mod download
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG VERSION=devel-docker
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN --mount=type=cache,target=/root/.cache npm ci && npm run assets
|
RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/root/go GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GOARM=7 go build -gcflags "all=-N -l" -o /app/bin/osiris -ldflags "-s -w -extldflags -static -X github.com/TecharoHQ/anubis.Version=${VERSION}" ./cmd/osiris
|
||||||
RUN --mount=type=cache,target=/root/.cache GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 GOARM=7 go build -gcflags "all=-N -l" -o /app/bin/osiris -ldflags "-s -w -extldflags -static -X github.com/TecharoHQ/anubis.Version=${VERSION}" ./cmd/osiris
|
|
||||||
|
|
||||||
FROM alpine:${ALPINE_VERSION} AS run
|
FROM alpine:${ALPINE_VERSION} AS run
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -23,7 +25,6 @@ RUN apk -U add ca-certificates mailcap
|
|||||||
|
|
||||||
COPY --from=build /app/bin/osiris /app/bin/osiris
|
COPY --from=build /app/bin/osiris /app/bin/osiris
|
||||||
|
|
||||||
CMD ["/app/bin/anubis"]
|
CMD ["/app/bin/osiris"]
|
||||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/bin/anubis", "--healthcheck" ]
|
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis"
|
LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis"
|
||||||
Reference in New Issue
Block a user