Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add rock for traefik v3.1.0 #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions 3.1.0/files/traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
log:
level: DEBUG

providers:
file:
directory: /etc/traefik
watch: true

entryPoints:
web:
address: ":8080"
websecure:
address: ":8081"
108 changes: 108 additions & 0 deletions 3.1.0/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: traefik
summary: Traefik in a rock.
description: "Traefik is the a cloud-native application networking stack."
version: "3.1.0"
base: [email protected]
license: Apache-2.0
# sources:
# jnsgruk's traefik dockerfile https://github.com/jnsgruk/traefik-oci-image/blob/main/Dockerfile
# upstream traefik makefile https://github.com/traefik/traefik/blob/84a081054688349fa4e2513599e3bf2395331492/Makefile

# /
# ├── bin
# │ └── traefik
# └── etc
# └── traefik.yaml
services:
traefik:
command: /bin/traefik
override: replace
startup: enabled
platforms:
amd64:
parts:
traefik-frontend:
plugin: npm
source-type: git
source-depth: 1
source-tag: "v3.1.0"
source: https://github.com/traefik/traefik
npm-node-version: 14.16
build-packages:
- nodejs
- npm
override-build: |
npm install -g yarn && \
cd ./webui && \
# added --legacy-peer-deps to avoid dependency resolution errors with mocha (testing)
npm install --legacy-peer-deps && \
# Build the bundle as per:
# https://github.com/traefik/traefik/blob/84a081054688349fa4e2513599e3bf2395331492/Makefile#L66
npm run build:nc && \
# cleanup
rm -rf node_modules
default-config:
plugin: dump
source: files
organize:
traefik.yaml: etc/traefik/traefik.yaml
stage:
- etc/traefik/traefik.yaml
traefik:
plugin: go
source-type: git
source-depth: 1
source-tag: "v3.1.0"
source: https://github.com/traefik/traefik
build-snaps:
- yq
- go/1.22/stable
build-environment:
- GO111MODULE: "on"
- CGO_ENABLED: "0"
- GOGC: "off"
- TRAEFIK_VERSION: v3.1.0
override-build: |
CODENAME=$(yq e '.blocks[] | select(.name=="Release").task.env_vars[] | select(.name=="CODENAME").value' ./.semaphore/semaphore.yml) && \
mkdir -p dist && \
# Required to merge non-code components into the final binary such as the web dashboard/UI
go generate && \
# Build Traefik per https://github.com/traefik/traefik/raw/v2.6.1/script/binary
go build -ldflags "-s -w \
-X github.com/traefik/traefik/v2/pkg/version.Version=$TRAEFIK_VERSION \
-X github.com/traefik/traefik/v2/pkg/version.Codename=$CODENAME \
-X github.com/traefik/traefik/v2/pkg/version.BuildDate=$(date -u '+%Y-%m-%d_%I:%M:%S%p')" \
-a -installsuffix nocgo -o $CRAFT_PART_INSTALL/traefik ./cmd/traefik
after:
- traefik-frontend
organize:
traefik: bin/traefik
stage:
- bin/traefik
stage-packages:
- ca-certificates
# We moved this here because: https://github.com/canonical/rockcraft/issues/343
ca-certs:
plugin: nil
overlay-packages: [ca-certificates]
non-root-user:
plugin: nil
after: [default-config]
overlay-script: |
# Create a user in the $CRAFT_OVERLAY chroot
groupadd -R $CRAFT_OVERLAY -g 1000 traefik
useradd -R $CRAFT_OVERLAY -M -r -g traefik -u 1000 traefik
override-prime: |
craftctl default
chown -R 1000:1000 etc/traefik
deb-security-manifest:
plugin: nil
after:
- traefik
- traefik-frontend
- ca-certs
override-prime: |
set -x
mkdir -p $CRAFT_PRIME/usr/share/rocks/
(echo "# os-release" && cat /etc/os-release && echo "# dpkg-query" && dpkg-query --admindir=$CRAFT_PRIME/var/lib/dpkg/ -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) > $CRAFT_PRIME/usr/share/rocks/dpkg.query
# TODO verification steps and testing framework