From 557b221c8b00995ee40dde3daaa091a947770041 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Sat, 23 Jan 2021 01:01:56 +0100 Subject: [PATCH] initial commit --- .drone.yml | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 + Dockerfile | 33 ++++++++++++ renovate.json | 62 +++++++++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 .drone.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 renovate.json diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..7553ca2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,137 @@ +kind: pipeline +type: docker +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: + - name: docker + image: plugins/docker + settings: + purge: true + no_cache: true + auto_tag: true + auto_tag_suffix: linux-amd64 + repo: spcodes/filtron + build_args: + - ARCH=amd64 + username: + from_secret: USERNAME + password: + from_secret: PASSWORD + +trigger: + branch: + - main + event: + - push + +--- +kind: pipeline +type: docker +name: linux-arm + +platform: + os: linux + arch: arm + +steps: + - name: docker + image: plugins/docker + settings: + purge: true + no_cache: true + auto_tag: true + auto_tag_suffix: linux-arm + repo: spcodes/filtron + build_args: + - ARCH=arm + username: + from_secret: USERNAME + password: + from_secret: PASSWORD + +trigger: + branch: + - main + event: + - push + +--- +kind: pipeline +type: docker +name: linux-arm64 + +platform: + os: linux + arch: arm64 + +steps: + - name: docker + image: plugins/docker + settings: + purge: true + no_cache: true + auto_tag: true + auto_tag_suffix: linux-arm64 + repo: spcodes/filtron + build_args: + - ARCH=arm64 + username: + from_secret: USERNAME + password: + from_secret: PASSWORD + +trigger: + branch: + - main + event: + - push + +--- +kind: pipeline +type: docker +name: manifest + +steps: + - name: publish-version + image: plugins/manifest + settings: + ignore_missing: true + target: spcodes/filtron:v0.1.0 + template: spcodes/filtron:OS-ARCH + platforms: + - linux/amd64 + - linux/arm64 + - linux/arm + username: + from_secret: USERNAME + password: + from_secret: PASSWORD + - name: publish-latest + image: plugins/manifest + settings: + ignore_missing: true + target: spcodes/filtron + template: spcodes/filtron:OS-ARCH + platforms: + - linux/amd64 + - linux/arm64 + - linux/arm + username: + from_secret: USERNAME + password: + from_secret: PASSWORD + +depends_on: + - linux-amd64 + - linux-arm64 + - linux-arm + +trigger: + branch: + - main + event: + - push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1062418 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +*.iml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9f39cf4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +ARG ARCH + +# STEP 1 build executable binary +FROM amd64/golang:1.15.7-alpine3.12@sha256:9f88dc7df11a83b9641d71b4be4f8ccbfb2342e5cb733661363ed3d0a98fe3ef AS builder-amd64 +FROM arm32v7/golang:1.15.7-alpine3.12@sha256:d54bff25a171d1b3036bf6b5dea2bbfaf75b7518e9b780a046750d8e26a19253 AS builder-arm +FROM arm64v8/golang:1.15.7-alpine3.12@sha256:e5389316a6dc295d6c0ca269c39124ad5bc9ebb416c71c810822cf6fbcf8ff01 AS builder-arm64 +FROM builder-${ARCH} AS builder + +ENV FILTRON_VERSION="v0.1.0" + +WORKDIR $GOPATH/src/github.com/asciimoo/filtron + +RUN apk add --no-cache tar="1.32-r1" git="2.26.2-r0" curl="7.69.1-r3" \ + && curl -L "https://github.com/asciimoo/filtron/archive/${FILTRON_VERSION}.tar.gz" | tar xvz --strip 1 + +RUN go get -d -v && gofmt -l ./ && go build . + +# STEP 2 build the image including only the binary +FROM amd64/alpine:3.12.3@sha256:074d3636ebda6dd446d0d00304c4454f468237fdacf08fb0eeac90bdbfa1bac7 AS base-amd64 +FROM arm32v7/alpine:3.12.3@sha256:299294be8699c1b323c137f972fd0aa5eaa4b95489c213091dcf46ef39b6c810 AS base-arm +FROM arm64v8/alpine:3.12.3@sha256:549694ea68340c26d1d85c00039aa11ad835be279bfd475ff4284b705f92c24e AS base-arm64 +FROM base-${ARCH} + +RUN apk --no-cache add ca-certificates="20191127-r4" \ + && adduser -D -h /usr/local/filtron -s /bin/false filtron filtron + +COPY --from=builder /go/src/github.com/asciimoo/filtron/example_rules.json /etc/filtron/rules.json +COPY --from=builder /go/src/github.com/asciimoo/filtron/filtron /usr/local/filtron/filtron + +EXPOSE 3000 +USER filtron + +ENTRYPOINT ["/usr/local/filtron/filtron", "--rules", "/etc/filtron/rules.json"] diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..9c55794 --- /dev/null +++ b/renovate.json @@ -0,0 +1,62 @@ +{ + "assignees": [ + "samuel-p" + ], + "baseBranches": [ + "main" + ], + "rangeStrategy": "bump", + "rebaseWhen": "behind-base-branch", + "regexManagers": [ + { + "fileMatch": [ + "^Dockerfile$", + "^.drone.yml$" + ], + "matchStrings": [ + "\\s+ENV\\s*FILTRON_VERSION=\"(?.*?)\"\\s+", + "\\s+target:\\s*spcodes\\/filtron:(?.*?)\\s+" + ], + "versioningTemplate": "loose", + "depNameTemplate": "asciimoo/filtron", + "datasourceTemplate": "github-releases" + }, + { + "fileMatch": [ + "^Dockerfile$" + ], + "matchStrings": [ + "\\s+(?[a-z0-9\\-]+?)=\"(?.*?)\"" + ], + "lookupNameTemplate": "alpine_3_12/{{{depName}}}", + "versioningTemplate": "loose", + "datasourceTemplate": "repology" + } + ], + "packageRules": [ + { + "datasources": [ + "github-releases" + ], + "groupName": [ + "filtron" + ] + }, + { + "datasources": [ + "repology" + ], + "groupName": [ + "base dependencies" + ] + }, + { + "datasources": [ + "docker" + ], + "groupName": [ + "docker images" + ] + } + ] +}