This commit is contained in:
parent
aa7498d93e
commit
2d2e251f0b
@ -1,8 +1,56 @@
|
|||||||
steps:
|
steps:
|
||||||
build:
|
build:
|
||||||
|
image: golang:1.22.5-alpine3.20
|
||||||
|
commands:
|
||||||
|
- GOPATH=/woodpecker/go
|
||||||
|
- ls -l
|
||||||
|
- cd src/tsm
|
||||||
|
- go mod tidy
|
||||||
|
- go build -a -installsuffix nocgo -o tsm tsm.go
|
||||||
|
- cp tsm ../..
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
|
scan:
|
||||||
|
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
||||||
|
environment:
|
||||||
|
TRIVY_TOKEN:
|
||||||
|
from_secret: trivy_token
|
||||||
|
TRIVY_URL:
|
||||||
|
from_secret: trivy_url
|
||||||
|
DTRACK_API_KEY:
|
||||||
|
from_secret: dtrack_api_key
|
||||||
|
DTRACK_API_URL:
|
||||||
|
from_secret: dtrack_api_url
|
||||||
|
commands:
|
||||||
|
- export GOPATH=/woodpecker/go # the export is required, otherwise trivy will not consider the variable
|
||||||
|
- HOME=/home/`id -nu`
|
||||||
|
- TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||||
|
- |
|
||||||
|
trivy fs \
|
||||||
|
--server $TRIVY_URL \
|
||||||
|
--token $TRIVY_TOKEN \
|
||||||
|
--format cyclonedx \
|
||||||
|
--scanners license \
|
||||||
|
--output /tmp/sbom.xml \
|
||||||
|
.
|
||||||
|
- cat /tmp/sbom.xml
|
||||||
|
- |
|
||||||
|
curl -X "POST" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-H "X-Api-Key: $DTRACK_API_KEY" \
|
||||||
|
-F "autoCreate=true" \
|
||||||
|
-F "projectName=$CI_REPO" \
|
||||||
|
-F "projectVersion=$TAG" \
|
||||||
|
-F "bom=@/tmp/sbom.xml"\
|
||||||
|
"$DTRACK_API_URL/api/v1/bom"
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
|
dockerize:
|
||||||
image: plugins/kaniko
|
image: plugins/kaniko
|
||||||
settings:
|
settings:
|
||||||
repo: gitea.hottis.de/wn/snmp-mqtt
|
repo: ${FORGE_NAME}/${CI_REPO}
|
||||||
registry:
|
registry:
|
||||||
from_secret: container_registry
|
from_secret: container_registry
|
||||||
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
|
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
|
||||||
@ -15,10 +63,10 @@ steps:
|
|||||||
- event: [push, tag]
|
- event: [push, tag]
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
image: portainer/kubectl-shell:latest
|
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
||||||
secrets:
|
environment:
|
||||||
- source: kube_config
|
KUBE_CONFIG_CONTENT:
|
||||||
target: KUBE_CONFIG_CONTENT
|
from_secret: kube_config
|
||||||
commands:
|
commands:
|
||||||
- export IMAGE_TAG=$CI_COMMIT_TAG
|
- export IMAGE_TAG=$CI_COMMIT_TAG
|
||||||
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
|
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
|
||||||
@ -26,3 +74,4 @@ steps:
|
|||||||
- ./deployment/deploy.sh
|
- ./deployment/deploy.sh
|
||||||
when:
|
when:
|
||||||
- event: tag
|
- event: tag
|
||||||
|
|
||||||
|
10
Dockerfile
10
Dockerfile
@ -1,16 +1,8 @@
|
|||||||
FROM golang:1.21-alpine as builder
|
|
||||||
|
|
||||||
RUN mkdir -p /go/src
|
|
||||||
COPY ./src /go/src
|
|
||||||
WORKDIR /go/src/smq
|
|
||||||
RUN go build -a -installsuffix nocgo -o smq snmp-mqtt.go
|
|
||||||
|
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
ENV SNMP_MQTT_CONF ""
|
ENV SNMP_MQTT_CONF ""
|
||||||
|
|
||||||
COPY --from=builder /go/src/smq ./
|
COPY smq ./
|
||||||
ENTRYPOINT ["./smq"]
|
ENTRYPOINT ["./smq"]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user