Drone CI docker package building
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/.bin
|
||||||
|
*.gz
|
||||||
|
*.br
|
||||||
|
*.zst
|
54
.drone.yml
54
.drone.yml
@@ -6,6 +6,10 @@ platform:
|
|||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: "0"
|
CGO_ENABLED: "0"
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -17,13 +21,17 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- apk update
|
- apk update
|
||||||
- apk add --no-cache git
|
- apk add --no-cache git
|
||||||
- go build -v ./cmd/go-away
|
- mkdir .bin
|
||||||
|
- go build -v -o ./.bin/go-away ./cmd/go-away
|
||||||
|
- go build -v -o ./.bin/test-wasm-runtime ./cmd/test-wasm-runtime
|
||||||
|
|
||||||
- name: test-wasm-success
|
- name: test-wasm-success
|
||||||
image: golang:1.22-alpine3.20
|
image: golang:1.22-alpine3.20
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
commands:
|
commands:
|
||||||
- >
|
- >
|
||||||
go run ./cmd/test-wasm-runtime -wasm ./embed/challenge/js-pow-sha256/runtime/runtime.wasm
|
./.bin/test-wasm-runtime -wasm ./embed/challenge/js-pow-sha256/runtime/runtime.wasm
|
||||||
-make-challenge ./embed/challenge/js-pow-sha256/test/make-challenge.json
|
-make-challenge ./embed/challenge/js-pow-sha256/test/make-challenge.json
|
||||||
-make-challenge-out ./embed/challenge/js-pow-sha256/test/make-challenge-out.json
|
-make-challenge-out ./embed/challenge/js-pow-sha256/test/make-challenge-out.json
|
||||||
-verify-challenge ./embed/challenge/js-pow-sha256/test/verify-challenge.json
|
-verify-challenge ./embed/challenge/js-pow-sha256/test/verify-challenge.json
|
||||||
@@ -31,9 +39,11 @@ steps:
|
|||||||
|
|
||||||
- name: test-wasm-fail
|
- name: test-wasm-fail
|
||||||
image: golang:1.22-alpine3.20
|
image: golang:1.22-alpine3.20
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
commands:
|
commands:
|
||||||
- >
|
- >
|
||||||
go run ./cmd/test-wasm-runtime -wasm ./embed/challenge/js-pow-sha256/runtime/runtime.wasm
|
./.bin/test-wasm-runtime -wasm ./embed/challenge/js-pow-sha256/runtime/runtime.wasm
|
||||||
-make-challenge ./embed/challenge/js-pow-sha256/test/make-challenge.json
|
-make-challenge ./embed/challenge/js-pow-sha256/test/make-challenge.json
|
||||||
-make-challenge-out ./embed/challenge/js-pow-sha256/test/make-challenge-out.json
|
-make-challenge-out ./embed/challenge/js-pow-sha256/test/make-challenge-out.json
|
||||||
-verify-challenge ./embed/challenge/js-pow-sha256/test/verify-challenge-fail.json
|
-verify-challenge ./embed/challenge/js-pow-sha256/test/verify-challenge-fail.json
|
||||||
@@ -47,6 +57,10 @@ platform:
|
|||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: "0"
|
CGO_ENABLED: "0"
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -67,6 +81,10 @@ platform:
|
|||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
arch: arm64
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
CGO_ENABLED: "0"
|
CGO_ENABLED: "0"
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
@@ -79,5 +97,35 @@ steps:
|
|||||||
- apk update
|
- apk update
|
||||||
- apk add --no-cache git
|
- apk add --no-cache git
|
||||||
- go build -v ./cmd/go-away
|
- go build -v ./cmd/go-away
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: publish-docker
|
||||||
|
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: docker
|
||||||
|
image: plugins/buildx
|
||||||
|
settings:
|
||||||
|
registry: git.gammaspectra.live
|
||||||
|
repo: git.gammaspectra.live/git/go-away
|
||||||
|
squash: true
|
||||||
|
compress: true
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
builder_driver: docker-container
|
||||||
|
auto_tag: true
|
||||||
|
username:
|
||||||
|
from_secret: git_username
|
||||||
|
password:
|
||||||
|
from_secret: git_password
|
||||||
|
|
||||||
|
#trigger:
|
||||||
|
# event:
|
||||||
|
# - promote
|
||||||
|
# target:
|
||||||
|
# - production
|
||||||
...
|
...
|
||||||
|
|
||||||
|
20
Dockerfile
20
Dockerfile
@@ -1,7 +1,12 @@
|
|||||||
ARG from_builder=golang:1.24-alpine3.21
|
ARG from_builder=golang:1.24-alpine3.21
|
||||||
ARG from=alpine:3.21
|
ARG from=alpine:3.21
|
||||||
|
|
||||||
FROM ${from_builder} AS build
|
ARG TARGETPLATFORM
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
|
||||||
|
FROM --platform=$BUILDPLATFORM ${from_builder} AS build
|
||||||
|
|
||||||
RUN apk update && apk add --no-cache \
|
RUN apk update && apk add --no-cache \
|
||||||
bash \
|
bash \
|
||||||
@@ -10,24 +15,19 @@ RUN apk update && apk add --no-cache \
|
|||||||
|
|
||||||
ENV GOBIN="/go/bin"
|
ENV GOBIN="/go/bin"
|
||||||
|
|
||||||
ARG GOAWAY_REF="master"
|
COPY . .
|
||||||
|
|
||||||
RUN git clone https://git.gammaspectra.live/git/go-away.git /src/go-away
|
|
||||||
WORKDIR /src/go-away
|
|
||||||
|
|
||||||
RUN git reset --hard "${GOAWAY_REF}"
|
|
||||||
|
|
||||||
RUN ./build-compress.sh
|
RUN ./build-compress.sh
|
||||||
|
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
ENV GOOS=linux
|
ENV GOOS=${TARGETOS}
|
||||||
ENV GOARCH=amd64
|
ENV GOARCH=${TARGETARCH}
|
||||||
|
|
||||||
RUN go build -pgo=auto -v -trimpath -o "${GOBIN}/go-away" ./cmd/go-away
|
RUN go build -pgo=auto -v -trimpath -o "${GOBIN}/go-away" ./cmd/go-away
|
||||||
RUN test -e "${GOBIN}/go-away"
|
RUN test -e "${GOBIN}/go-away"
|
||||||
|
|
||||||
|
|
||||||
FROM ${from}
|
FROM --platform=$TARGETPLATFORM ${from}
|
||||||
|
|
||||||
COPY --from=build /go/bin/go-away /bin/go-away
|
COPY --from=build /go/bin/go-away /bin/go-away
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user