2 Commits

Author SHA1 Message Date
b68e929c57 add incomplete ci script 2024-01-23 16:15:26 +01:00
89089f429c add Dockerfile 2024-01-23 16:12:50 +01:00
3 changed files with 51 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
build
.DS_Store
snmp-mqtt

29
.woodpecker.yml Normal file
View File

@ -0,0 +1,29 @@
steps:
build:
image: plugins/kaniko
settings:
repo: gitea.hottis.de/wn/snmp-mqtt
registry:
from_secret: container_registry
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
username:
from_secret: container_registry_username
password:
from_secret: container_registry_password
dockerfile: Dockerfile
when:
- event: [push, tag]
deploy:
image: portainer/kubectl-shell:latest
secrets:
- source: kube_config
target: KUBE_CONFIG_CONTENT
- source: image_name
target: IMAGE_NAME
commands:
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
- export KUBECONFIG=/tmp/kubeconfig
- cat $CI_WORKSPACE/deployment/deploy-yml.tmpl | sed -e 's,%IMAGE%,'$IMAGE_NAME':'$CI_COMMIT_TAG',' | kubectl apply -f -
when:
- event: tag

21
Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM golang:1.21-alpine as builder
RUN mkdir -p /go/src /go/src/snmp /go/src/config
COPY ./snmp-mqtt.go /go/src
COPY ./snmp/ /go/src/snmp
COPY ./config/ /go/src/config
COPY ./go.mod /go/src
COPY ./go.sum /go/src
WORKDIR /go/src
RUN go mod tidy && go build -a -installsuffix nocgo -o snmp-mqtt github.com/dchote/snmp-mqtt
FROM scratch
ENV SNMP_MQTT_CONF ""
COPY --from=builder /go/src/snmp-mqtt ./
ENTRYPOINT ["./snmp-mqtt"]