From da9fc6e5bf214046a79be0181b145ff4f2b4bbfe Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 16:52:02 +0100 Subject: [PATCH 1/7] Multi-arch images --- .github/dependabot.yml | 8 ++ .github/labels.yml | 12 ++ .github/release-drafter.yml | 33 ++++++ .github/workflows/action_branch.yml | 33 ++++++ .github/workflows/action_pull_request.yml | 35 ++++++ .github/workflows/action_schedule.yml | 35 ++++++ .github/workflows/lint.yml | 22 ++++ .github/workflows/params.yml | 70 +++++++++++ .github/workflows/release-drafter.yml | 19 +++ .github/workflows/repository.yml | 25 ++++ .gitignore | 88 +------------- .travis.yml | 70 ----------- .yamllint | 13 ++ Dockerfile | 40 +++---- Dockerfiles/Dockerfile.latest | 1 + Dockerfiles/Dockerfile.stretch | 40 +++++++ .../data}/docker-entrypoint.sh | 0 {data => Dockerfiles/data}/ngrok.yml | 0 Makefile | 112 ++++++++++++++---- README.md | 23 +++- tests/test.sh | 4 +- 21 files changed, 482 insertions(+), 201 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/labels.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/action_branch.yml create mode 100644 .github/workflows/action_pull_request.yml create mode 100644 .github/workflows/action_schedule.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/params.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/repository.yml delete mode 100644 .travis.yml create mode 100644 .yamllint create mode 120000 Dockerfiles/Dockerfile.latest create mode 100644 Dockerfiles/Dockerfile.stretch rename {data => Dockerfiles/data}/docker-entrypoint.sh (100%) rename {data => Dockerfiles/data}/ngrok.yml (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8e85703 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +--- +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..9a507e8 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,12 @@ +# The labels in this file are automatically synced with the repository +# using the micnncim/action-label-syncer action. +--- +- name: C-dependency + color: 1abc9c + description: "Category: Dependency" +- name: PR-block + color: 3498db + description: "Pull Request: Do not merge" +- name: PR-merge + color: 3498db + description: "Pull Request: Merge when ready" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..03439b4 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,33 @@ +--- +name-template: '$RESOLVED_VERSION 🌈' +tag-template: '$RESOLVED_VERSION' +version-template: '$MAJOR.$MINOR' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: minor +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml new file mode 100644 index 0000000..3197415 --- /dev/null +++ b/.github/workflows/action_branch.yml @@ -0,0 +1,33 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + push: + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master + with: + enabled: true + can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml new file mode 100644 index 0000000..21b075b --- /dev/null +++ b/.github/workflows/action_pull_request.yml @@ -0,0 +1,35 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + pull_request: + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + # Only run for forks (contributor) + if: github.event.pull_request.head.repo.fork + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master + with: + enabled: true + can_deploy: false + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: "" + dockerhub_password: "" diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml new file mode 100644 index 0000000..c25dfa2 --- /dev/null +++ b/.github/workflows/action_schedule.yml @@ -0,0 +1,35 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: nightly + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + # Runs daily + schedule: + - cron: '0 0 * * *' + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master + with: + enabled: true + can_deploy: true + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..f83d099 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: lint + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + # Runs on Pull Requests + pull_request: + + +# ------------------------------------------------------------------------------------------------- +# What to run +# ------------------------------------------------------------------------------------------------- +jobs: + lint: + uses: devilbox/github-actions/.github/workflows/lint-generic.yml@master diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml new file mode 100644 index 0000000..7225fd3 --- /dev/null +++ b/.github/workflows/params.yml @@ -0,0 +1,70 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: params + + +# ------------------------------------------------------------------------------------------------- +# Custom Variables +# ------------------------------------------------------------------------------------------------- +env: + MATRIX: >- + [ + { + "NAME": "ngrok", + "VERSION": ["2"], + "FLAVOUR": ["latest", "stretch"], + "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] + } + ] + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + workflow_call: + outputs: + matrix: + description: "The determined version matrix" + value: ${{ jobs.params.outputs.matrix }} + refs: + description: "The determined git ref matrix (only during scheduled run)" + value: ${{ jobs.params.outputs.refs }} + +jobs: + params: + runs-on: ubuntu-latest + + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + refs: ${{ steps.set-refs.outputs.matrix }} + + steps: + - name: "[Set-Output] Matrix" + id: set-matrix + run: | + echo "::set-output name=matrix::$( echo '${{ env.MATRIX }}' | jq -M -c )" + + - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" + id: set-refs + uses: cytopia/git-ref-matrix-action@v0.1.4 + with: + repository_default_branch: master + branches: master + num_latest_tags: 1 + if: github.event_name == 'schedule' + + - name: "[DEBUG] Show settings'" + run: | + echo 'Matrix' + echo '--------------------' + echo '${{ steps.set-matrix.outputs.matrix }}' + echo + + echo 'Matrix: Refs' + echo '--------------------' + echo '${{ steps.set-matrix-refs.outputs.matrix }}' + echo diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..1a63d7e --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +--- +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + publish: true + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }} diff --git a/.github/workflows/repository.yml b/.github/workflows/repository.yml new file mode 100644 index 0000000..ca21e7d --- /dev/null +++ b/.github/workflows/repository.yml @@ -0,0 +1,25 @@ +--- +name: Repository + +on: + push: + branches: + - master + paths: + - .github/labels.yml + +jobs: + labels: + name: Labels + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Sync labels + uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + manifest: .github/labels.yml diff --git a/.gitignore b/.gitignore index cc3a8c2..7457dff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,86 +1,2 @@ -# Note: -# To effectively apply the changes you will have -# to re-index the git index (if there are already -# commited files) -# -# $ git rm -r --cached . -# $ git add . -# $ git commit -m ".gitignore index rebuild" -# - - -###################################### -# CUSTOM -###################################### - - -###################################### -# GENERIC -###################################### - -###### std ###### -.lock -*.log - -###### patches/diffs ###### -*.patch -*.diff -*.orig -*.rej - - -###################################### -# Operating Systems -###################################### - -###### OSX ###### -._* -.DS* -.Spotlight-V100 -.Trashes - -###### Windows ###### -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.lnk -*.shortcut - -###################################### -# Editors -###################################### - -###### Sublime ###### -*.sublime-workspace -*.sublime-project - -###### Eclipse ###### -.classpath -.buildpath -.project -.settings/ - -###### Netbeans ###### -/nbproject/ - -###### Intellij IDE ###### -.idea/ -.idea_modules/ - -###### vim ###### -*.swp -*.swo -*.swn -*.swm -*~ - -###### TextMate ###### -.tm_properties -*.tmproj - -###### BBEdit ###### -*.bbprojectd -*.bbproject - -.vagrant +Makefile.docker +Makefile.lint diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da7f505..0000000 --- a/.travis.yml +++ /dev/null @@ -1,70 +0,0 @@ -### -### Enable sudo (required for docker service) -### -sudo: required - - -### -### Language -### -language: python - - -### -### Add services -### -services: - - docker - - -### -### Build Matrix definition -### -env: - global: - # travis encrypt DOCKER_USERNAME=user - # travis encrypt DOCKER_PASSWORD=pass - # Must be regenerated when repository name/owner changes - # DOCKER_USERNAME - - secure: "iQ9JT1Nz7tgTlaG4iQG8PrI96Asge/rLpBaIlIRBRgKE9OSjfPDwdUQEQTOm0XstdompqUWtTdx2ffmcF7B5eEoYCBZR+I+UDmlRxPdCygo/um3SQKHXPYJs2Jb6XfQKgsNnp8PTrbvg95Ol8bjxBEM1ilS88gwZjBOL7l9B93vntV6ALMERioq6L5nuD7DHRKWAkRXAbXY6bBvS9wPZLp+KD84AoaVJfzOBFuwbh1inqQn2a9E1LAz3moyJt3IMLfoAiLWBM0kW/svLkMuXFoeHH2mslJGcDJEEF5YRdaP5HArtvTMdAwkJl3CEVtu2lhZlhxTDuoHjwTPXtTAFNRoGcQ/USB+rylaPfdunuECgo4bv7eR07ClaYX5o5HnNmxStZlPT+71d1wFncFSO/qbjA5OzMxlvIzMfPPcCwNlwdS4RVgzuezxD9mxvgLIHG7hasMpKfS5V6boSZxcj3blHAFrwW8I+c9EqhSgiFWaTfHj3wKcGfMUPfQdbjPoQVF5Zw9lJnT64azCAjY4xy6YMkc4oyIr1HOuBe3MeoyD++loIc3CmUqe2TWVbrbkhhQ/h40v+MJcgPLM4kHLlJZa1WTNYQRto50Pw+gixiEIUuKPUDUi4BucYG3AIlFnnOLyR2b/phC7TxQU8HRCLbPUwy3xS+M7NJgDHlIUKBPs=" - # DOCKER_PASSWORD - - secure: "Vui8u1T8uviGn/aKWxWHEwphW3j6L0kfk+P6sFipuJPpCA9x0SDKmDjBaVeyoCO1r5PnzXLSLzG8yB4ylY+QWmlUIkJWI2iy96N1O2NyLDkG8mZs4+tC9dtHB9gMIxkcKK7udtsf/05tD/iPhsAv/a6SsyX/up/8oHfzn0exG34Ks6rwoXr8rZI8VoF37lZpidwHQyqxSejZ3aKrzquazHECtMIEc6X5DwMlPCPUEQPPQ8yavlJN0OFcQ/A7NH5vN0aDnd8YdwtaigAt0U62tRdQ0jLS3AUf7smfNDhhm4WdBmWzJnT4rwupzS2LnlXjfp6d6gSJ+eehwqhSuKLadzO9PISHOeb58YfDADV2n55/p0LkHt7zsVs28Xd9VXZol5pTCjf4RkGZeATENRQKOTvpvXcjCItbcWqGqkyDo8vALx2vU1ybpQB8UBxAZl05y2N8t0ZqSHU55k7ogMuTI5THS9zWFyIDlKjqtIw7l4vaE2M1w526OVm3W4QiPYBF2B+zJDE1/QYQYg3bhqjTcyJ2t4mt/OuXFbPFDoB3S3H8M85/8afZJHVG9Qlzb31gvyBYsHHkVYDFhyybaB4XGHC6cCBLS0YnTX6tUMt7RVoTEeXiliXOZQtgCc4nrGFx5cdbXLzPJsnGKdQPsQvb+DZfLilUihu0X7ArtpEr+KY=" - - -### -### Global for all stages -### -install: - # Get newer docker version - - max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get update; then break; else i=$((i+1)); fi done - - max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; then break; else i=$((i+1)); fi done - - docker version - - -### -### Build and test -### -before_script: - - make build - - make test - - -### -### Push to Dockerhub -### -script: - # Push to docker hub on success - - if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then - make login USER="${DOCKER_USERNAME}" PASS="${DOCKER_PASSWORD}"; - if [ -n "${TRAVIS_TAG}" ]; then - make push TAG="${TRAVIS_TAG}"; - elif [ "${TRAVIS_BRANCH}" == "master" ]; then - make push; - elif [[ ${TRAVIS_BRANCH} =~ ^(release-[.0-9]+)$ ]]; then - make push TAG="${TRAVIS_BRANCH}"; - else - echo "Skipping branch ${TRAVIS_BRANCH}"; - fi - else - echo "Skipping push on PR"; - fi diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..2c7758f --- /dev/null +++ b/.yamllint @@ -0,0 +1,13 @@ +--- +extends: default + +ignore: | + .yamllint + + +rules: + truthy: + allowed-values: ['true', 'false'] + check-keys: False + level: error + line-length: disable diff --git a/Dockerfile b/Dockerfile index 4dd3b37..2631437 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,33 @@ -FROM debian:stretch-slim -MAINTAINER "cytopia" +FROM debian:stretch-slim as builder -RUN set -x \ - && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ - curl \ +RUN set -eux \ + && DEBIAN_FRONTEND=noninteractive apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \ ca-certificates \ - unzip \ - && DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false apt-utils \ - && rm -rf /var/lib/apt/lists/* \ - \ - && URL="$( curl -sS https://ngrok.com/download | grep -Eo "href=\".+ngrok-stable-linux-amd64\.zip\"" | awk -F'\"' '{print $2}' )" \ - && curl -sS -o /tmp/ngrok.zip ${URL} \ - && unzip /tmp/ngrok.zip \ - && rm /tmp/ngrok.zip \ - && mv ngrok /usr/local/bin \ - && ngrok version | grep -E '^ngrok.+[.0-9]+$' \ - \ - && DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ curl \ - ca-certificates \ - unzip \ + dpkg-dev \ && rm -rf /var/lib/apt/lists/* +RUN set -eux \ + && URL="$( \ + curl -sS --fail https://ngrok.com/download \ + | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH)\.tgz" \ + | head -1 \ + )" \ + && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ + && tar xvfz /tmp/ngrok.tgz \ + && rm /tmp/ngrok.tgz \ + && mv ngrok /usr/local/bin \ + && ngrok version | grep -E '^ngrok.+[.0-9]+$' + + +FROM debian:stretch-slim as final RUN set -x \ && useradd -m -U -u 6737 -s /bin/bash ngrok \ && mkdir /home/ngrok/.ngrok2 \ && chown ngrok:ngrok /home/ngrok/.ngrok2 +COPY --from=builder /usr/local/bin/ngrok /usr/local/bin/ngrok COPY data/docker-entrypoint.sh /docker-entrypoint.sh COPY data/ngrok.yml /home/ngrok/.ngrok2/ngrok.yml diff --git a/Dockerfiles/Dockerfile.latest b/Dockerfiles/Dockerfile.latest new file mode 120000 index 0000000..fbdb415 --- /dev/null +++ b/Dockerfiles/Dockerfile.latest @@ -0,0 +1 @@ +Dockerfile.stretch \ No newline at end of file diff --git a/Dockerfiles/Dockerfile.stretch b/Dockerfiles/Dockerfile.stretch new file mode 100644 index 0000000..8383d17 --- /dev/null +++ b/Dockerfiles/Dockerfile.stretch @@ -0,0 +1,40 @@ +FROM debian:stretch-slim as builder + +RUN set -eux \ + && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ + ca-certificates \ + curl \ + dpkg-dev \ + && rm -rf /var/lib/apt/lists/* + +RUN set -eux \ + && URL="$( \ + curl -sS --fail https://ngrok.com/download \ + | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH)\.tgz" \ + | head -1 \ + )" \ + && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ + && tar xvfz /tmp/ngrok.tgz \ + && rm /tmp/ngrok.tgz \ + && mv ngrok /usr/local/bin \ + && ngrok version | grep -E '^ngrok.+[.0-9]+$' + + +FROM debian:stretch-slim as final +RUN set -x \ + && useradd -m -U -u 6737 -s /bin/bash ngrok \ + && mkdir /home/ngrok/.ngrok2 \ + && chown ngrok:ngrok /home/ngrok/.ngrok2 + +COPY --from=builder /usr/local/bin/ngrok /usr/local/bin/ngrok +COPY data/docker-entrypoint.sh /docker-entrypoint.sh +COPY data/ngrok.yml /home/ngrok/.ngrok2/ngrok.yml + +RUN set -x \ + && chown ngrok:ngrok /home/ngrok/.ngrok2/ngrok.yml + +USER ngrok +ENV user=ngrok + +CMD ["/docker-entrypoint.sh"] diff --git a/data/docker-entrypoint.sh b/Dockerfiles/data/docker-entrypoint.sh similarity index 100% rename from data/docker-entrypoint.sh rename to Dockerfiles/data/docker-entrypoint.sh diff --git a/data/ngrok.yml b/Dockerfiles/data/ngrok.yml similarity index 100% rename from data/ngrok.yml rename to Dockerfiles/data/ngrok.yml diff --git a/Makefile b/Makefile index 08fc84c..98e65d3 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,99 @@ -DIR = . -FILE = Dockerfile -IMAGE = devilbox/ngrok -TAG = latest +ifneq (,) +.error This Makefile requires GNU Make. +endif -.PHONY: build rebuild test tag pull login push enter +# Ensure additional Makefiles are present +MAKEFILES = Makefile.docker Makefile.lint +$(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@) +$(MAKEFILES): + @if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \ + echo "Error, curl or wget required."; \ + echo "Exiting."; \ + false; \ + fi +include $(MAKEFILES) -build: - docker build -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) +# Set default Target +.DEFAULT_GOAL := help -rebuild: pull - docker build --no-cache -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) -test: - ./tests/test.sh $(IMAGE) +# ------------------------------------------------------------------------------------------------- +# Default configuration +# ------------------------------------------------------------------------------------------------- +# Own vars +TAG = latest -tag: - docker tag $(IMAGE) $(IMAGE):$(TAG) +# Makefile.docker overwrites +NAME = ngrok +VERSION = 5.5 +IMAGE = devilbox/ngrok +FLAVOUR = latest +FILE = Dockerfile.$(FLAVOUR) +DIR = Dockerfiles +ifeq ($(strip $(FLAVOUR)),latest) +DOCKER_TAG = $(TAG) +else + ifeq ($(strip $(TAG)),latest) + DOCKER_TAG = $(FLAVOUR) + else + DOCKER_TAG = $(FLAVOUR)-$(TAG) + endif +endif +ARCH = linux/amd64 -pull: - docker pull $(shell grep FROM Dockerfile | sed 's/^FROM//g';) -login: - yes | docker login --username $(USER) --password $(PASS) +# Makefile.lint overwrites +FL_IGNORES = .git/,.github/,tests/ +SC_IGNORES = .git/,.github/,tests/ -push: - @$(MAKE) tag TAG=$(TAG) - docker push $(IMAGE):$(TAG) -enter: - docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=bash $(ARG) $(IMAGE) +# ------------------------------------------------------------------------------------------------- +# Default Target +# ------------------------------------------------------------------------------------------------- +.PHONY: help +help: + @echo "lint Lint project files and repository" + @echo + @echo "build [ARCH=...] [TAG=...] Build Docker image" + @echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache" + @echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub" + @echo + @echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest" + @echo "manifest-push [TAG=...] Push multi-arch manifest" + @echo + @echo "test [ARCH=...] Test built Docker image" + @echo + + +# ------------------------------------------------------------------------------------------------- +# Docker Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: build +build: docker-arch-build + +.PHONY: rebuild +rebuild: docker-arch-rebuild + +.PHONY: push +push: docker-arch-push + + +# ------------------------------------------------------------------------------------------------- +# Manifest Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: manifest-create +manifest-create: docker-manifest-create + +.PHONY: manifest-push +manifest-push: docker-manifest-push + + +# ------------------------------------------------------------------------------------------------- +# Test Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: test +test: _test-integration + +.PHONY: _test-integration +_test-integration: + ./tests/test.sh $(IMAGE) $(ARCH) $(DOCKER_TAG) diff --git a/README.md b/README.md index 76d1280..22455fe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Ngrok -[![Build Status](https://travis-ci.org/devilbox/docker-ngrok.svg?branch=master)](https://travis-ci.org/devilbox/docker-ngrok) +[![lint](https://github.com/devilbox/docker-ngrok/workflows/lint/badge.svg)](https://github.com/devilbox/docker-ngrok/actions?query=workflow%3Alint) +[![build](https://github.com/devilbox/docker-ngrok/workflows/build/badge.svg)](https://github.com/devilbox/docker-ngrok/actions?query=workflow%3Abuild) +[![nightly](https://github.com/devilbox/docker-ngrok/workflows/nightly/badge.svg)](https://github.com/devilbox/docker-ngrok/actions?query=workflow%3Anightly) + [![Tag](https://img.shields.io/github/tag/devilbox/docker-ngrok.svg)](https://github.com/devilbox/docker-ngrok/releases) [![Gitter](https://badges.gitter.im/devilbox/Lobby.svg)](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Discourse](https://img.shields.io/discourse/https/devilbox.discourse.group/status.svg?colorB=%234CB697)](https://devilbox.discourse.group) @@ -8,10 +11,26 @@ [![](https://images.microbadger.com/badges/image/devilbox/ngrok.svg)](https://microbadger.com/images/devilbox/ngrok "ngrok") [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) +**Available Architectures:** `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` + | Docker Hub | Upstream Project | |------------|------------------| | | | +## Available Docker tags + +| Docker Tag | Description | +|---------------------------------|--------------------------------------------------------------| +| `latest` | Latest Debian Stretch image (default) | +| `stretch` | Latest Debian Stretch image | +| | | +| `[0-9]\.[0-9]+` | Git tagged Debian Sretch image. E.g: `0.53` | +| `stretch-[0-9]\.[0-9]+` | Git tagged Debian Stretch image. E.g: `stretch-0.53` | +| | | +| `release-[0-9]\.[0-9]+` | Git branch Debian Stretch image. E.g: `release-0.53` | +| `stretch-release-[0-9]\.[0-9]+` | Git branch Debian Stretch image. E.g: `stretch-release-0.53` | + + ## Documentation @@ -87,7 +106,7 @@ HTTP_TUNNELS=project1.loc:localhost:8080 # Make two vhosts available which run on host apache:80 HTTP_TUNNELS=project1.loc:apache:80,project2.loc:apache:80 -# Make two vhosts from two different web server addresses available +# Make two vhosts from two different web server addresses available HTTP_TUNNELS=project1.loc:localhost:8080,project2.loc:apache:80 ``` diff --git a/tests/test.sh b/tests/test.sh index a1cb83c..da16222 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -5,5 +5,7 @@ set -u set -o pipefail IMAGE="${1}" +ARCH="${2}" +TAG="${3}" -docker run --rm --entrypoint=ngrok "${IMAGE}" version | grep -E '^ngrok\s+(version\s*)?[.0-9]+' +docker run --rm --platform "${ARCH}" --entrypoint=ngrok "${IMAGE}:${TAG}" version | grep -E '^ngrok\s+(version\s*)?[.0-9]+' From 696de74d01a1558019792dc8589f3a51386a6d7a Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 17:17:24 +0100 Subject: [PATCH 2/7] Add Docker Labels --- Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2631437..23240fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,27 @@ RUN set -eux \ FROM debian:stretch-slim as final + + +### +### Labels +### +# https://github.com/opencontainers/image-spec/blob/master/annotations.md +#LABEL "org.opencontainers.image.created"="" +#LABEL "org.opencontainers.image.version"="" +#LABEL "org.opencontainers.image.revision"="" +LABEL "maintainer"="cytopia " +LABEL "org.opencontainers.image.authors"="cytopia " +LABEL "org.opencontainers.image.url"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.documentation"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.source"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.vendor"="devilbox" +LABEL "org.opencontainers.image.licenses"="MIT" +LABEL "org.opencontainers.image.ref.name"="Ngrok" +LABEL "org.opencontainers.image.title"="Ngrok" +LABEL "org.opencontainers.image.description"="Ngrok" + + RUN set -x \ && useradd -m -U -u 6737 -s /bin/bash ngrok \ && mkdir /home/ngrok/.ngrok2 \ From 86d1f1de8be28cf999a59a8b48dbd8ac68fcdbe1 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 17:30:32 +0100 Subject: [PATCH 3/7] Add Alpine images --- Dockerfiles/Dockerfile.alpine | 59 ++++++++++++++++++++++++++++++++++ Dockerfiles/Dockerfile.stretch | 23 +++++++++++-- README.md | 3 ++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 Dockerfiles/Dockerfile.alpine diff --git a/Dockerfiles/Dockerfile.alpine b/Dockerfiles/Dockerfile.alpine new file mode 100644 index 0000000..16dad9d --- /dev/null +++ b/Dockerfiles/Dockerfile.alpine @@ -0,0 +1,59 @@ +FROM alpine as builder + +RUN set -eux \ + && apk add \ + ca-certificates \ + curl \ + dpkg \ + dpkg-dev + +RUN set -eux \ + && URL="$( \ + curl -sS --fail https://ngrok.com/download \ + | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH_CPU)\.tgz" \ + | head -1 \ + )" \ + && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ + && tar xvfz /tmp/ngrok.tgz \ + && rm /tmp/ngrok.tgz \ + && mv ngrok /usr/local/bin \ + && ngrok version | grep -E '^ngrok.+[.0-9]+$' + + +FROM alpine as final +### +### Labels +### +# https://github.com/opencontainers/image-spec/blob/master/annotations.md +#LABEL "org.opencontainers.image.created"="" +#LABEL "org.opencontainers.image.version"="" +#LABEL "org.opencontainers.image.revision"="" +LABEL "maintainer"="cytopia " +LABEL "org.opencontainers.image.authors"="cytopia " +LABEL "org.opencontainers.image.url"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.documentation"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.source"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.vendor"="devilbox" +LABEL "org.opencontainers.image.licenses"="MIT" +LABEL "org.opencontainers.image.ref.name"="ngrok" +LABEL "org.opencontainers.image.title"="ngrok" +LABEL "org.opencontainers.image.description"="ngrok" + +RUN set -x \ + && apk add bash \ + && addgroup -g 6837 ngrok \ + && adduser -h /home/ngrok -u 6737 -G ngrok -D -s /bin/bash ngrok \ + && mkdir /home/ngrok/.ngrok2 \ + && chown ngrok:ngrok /home/ngrok/.ngrok2 + +COPY --from=builder /usr/local/bin/ngrok /usr/local/bin/ngrok +COPY data/docker-entrypoint.sh /docker-entrypoint.sh +COPY data/ngrok.yml /home/ngrok/.ngrok2/ngrok.yml + +RUN set -x \ + && chown ngrok:ngrok /home/ngrok/.ngrok2/ngrok.yml + +USER ngrok +ENV user=ngrok + +CMD ["/docker-entrypoint.sh"] diff --git a/Dockerfiles/Dockerfile.stretch b/Dockerfiles/Dockerfile.stretch index 8383d17..055b42b 100644 --- a/Dockerfiles/Dockerfile.stretch +++ b/Dockerfiles/Dockerfile.stretch @@ -11,7 +11,7 @@ RUN set -eux \ RUN set -eux \ && URL="$( \ curl -sS --fail https://ngrok.com/download \ - | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH)\.tgz" \ + | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH_CPU)\.tgz" \ | head -1 \ )" \ && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ @@ -22,8 +22,27 @@ RUN set -eux \ FROM debian:stretch-slim as final + +### +### Labels +### +# https://github.com/opencontainers/image-spec/blob/master/annotations.md +#LABEL "org.opencontainers.image.created"="" +#LABEL "org.opencontainers.image.version"="" +#LABEL "org.opencontainers.image.revision"="" +LABEL "maintainer"="cytopia " +LABEL "org.opencontainers.image.authors"="cytopia " +LABEL "org.opencontainers.image.url"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.documentation"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.source"="https://github.com/devilbox/docker-ngrok" +LABEL "org.opencontainers.image.vendor"="devilbox" +LABEL "org.opencontainers.image.licenses"="MIT" +LABEL "org.opencontainers.image.ref.name"="ngrok" +LABEL "org.opencontainers.image.title"="ngrok" +LABEL "org.opencontainers.image.description"="ngrok" + RUN set -x \ - && useradd -m -U -u 6737 -s /bin/bash ngrok \ + && useradd -m -U -u 6737 -s /bin/bash ngrok \ && mkdir /home/ngrok/.ngrok2 \ && chown ngrok:ngrok /home/ngrok/.ngrok2 diff --git a/README.md b/README.md index 22455fe..e20c4be 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,15 @@ |---------------------------------|--------------------------------------------------------------| | `latest` | Latest Debian Stretch image (default) | | `stretch` | Latest Debian Stretch image | +| `alpine` | Latest Alpine image | | | | | `[0-9]\.[0-9]+` | Git tagged Debian Sretch image. E.g: `0.53` | | `stretch-[0-9]\.[0-9]+` | Git tagged Debian Stretch image. E.g: `stretch-0.53` | +| `alpine-[0-9]\.[0-9]+` | Git tagged Alpine image. E.g: `alpine-0.53` | | | | | `release-[0-9]\.[0-9]+` | Git branch Debian Stretch image. E.g: `release-0.53` | | `stretch-release-[0-9]\.[0-9]+` | Git branch Debian Stretch image. E.g: `stretch-release-0.53` | +| `alpine-release-[0-9]\.[0-9]+` | Git branch Alpine image. E.g: `alpine-release-0.53` | From 99df9fbee6457fceabaaa0b3ee2a8bb627795b59 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 18:51:03 +0100 Subject: [PATCH 4/7] Remove obsolete Dockerfile --- Dockerfile | 61 ------------------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 23240fa..0000000 --- a/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -FROM debian:stretch-slim as builder - -RUN set -eux \ - && DEBIAN_FRONTEND=noninteractive apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \ - ca-certificates \ - curl \ - dpkg-dev \ - && rm -rf /var/lib/apt/lists/* - -RUN set -eux \ - && URL="$( \ - curl -sS --fail https://ngrok.com/download \ - | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH)\.tgz" \ - | head -1 \ - )" \ - && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ - && tar xvfz /tmp/ngrok.tgz \ - && rm /tmp/ngrok.tgz \ - && mv ngrok /usr/local/bin \ - && ngrok version | grep -E '^ngrok.+[.0-9]+$' - - -FROM debian:stretch-slim as final - - -### -### Labels -### -# https://github.com/opencontainers/image-spec/blob/master/annotations.md -#LABEL "org.opencontainers.image.created"="" -#LABEL "org.opencontainers.image.version"="" -#LABEL "org.opencontainers.image.revision"="" -LABEL "maintainer"="cytopia " -LABEL "org.opencontainers.image.authors"="cytopia " -LABEL "org.opencontainers.image.url"="https://github.com/devilbox/docker-ngrok" -LABEL "org.opencontainers.image.documentation"="https://github.com/devilbox/docker-ngrok" -LABEL "org.opencontainers.image.source"="https://github.com/devilbox/docker-ngrok" -LABEL "org.opencontainers.image.vendor"="devilbox" -LABEL "org.opencontainers.image.licenses"="MIT" -LABEL "org.opencontainers.image.ref.name"="Ngrok" -LABEL "org.opencontainers.image.title"="Ngrok" -LABEL "org.opencontainers.image.description"="Ngrok" - - -RUN set -x \ - && useradd -m -U -u 6737 -s /bin/bash ngrok \ - && mkdir /home/ngrok/.ngrok2 \ - && chown ngrok:ngrok /home/ngrok/.ngrok2 - -COPY --from=builder /usr/local/bin/ngrok /usr/local/bin/ngrok -COPY data/docker-entrypoint.sh /docker-entrypoint.sh -COPY data/ngrok.yml /home/ngrok/.ngrok2/ngrok.yml - -RUN set -x \ - && chown ngrok:ngrok /home/ngrok/.ngrok2/ngrok.yml - -USER ngrok -ENV user=ngrok - -CMD ["/docker-entrypoint.sh"] From 6e6351364ea2b4e0aa7906066eaf88284c397b70 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 21:26:28 +0100 Subject: [PATCH 5/7] Use build-arg for platform specifics --- .github/workflows/params.yml | 2 +- Dockerfiles/Dockerfile.alpine | 7 +++---- Dockerfiles/Dockerfile.stretch | 4 ++-- Makefile | 2 ++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index 7225fd3..3b5eb1b 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -16,7 +16,7 @@ env: "NAME": "ngrok", "VERSION": ["2"], "FLAVOUR": ["latest", "stretch"], - "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] + "ARCH": ["linux/amd64", "linux/386", "linux/arm64"] } ] diff --git a/Dockerfiles/Dockerfile.alpine b/Dockerfiles/Dockerfile.alpine index 16dad9d..03889f5 100644 --- a/Dockerfiles/Dockerfile.alpine +++ b/Dockerfiles/Dockerfile.alpine @@ -1,16 +1,15 @@ FROM alpine as builder +ARG ARCH RUN set -eux \ && apk add \ ca-certificates \ - curl \ - dpkg \ - dpkg-dev + curl RUN set -eux \ && URL="$( \ curl -sS --fail https://ngrok.com/download \ - | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH_CPU)\.tgz" \ + | grep -Eo "http(s)?://.+ngrok-stable-${ARCH}\.tgz" \ | head -1 \ )" \ && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ diff --git a/Dockerfiles/Dockerfile.stretch b/Dockerfiles/Dockerfile.stretch index 055b42b..48d12f5 100644 --- a/Dockerfiles/Dockerfile.stretch +++ b/Dockerfiles/Dockerfile.stretch @@ -1,17 +1,17 @@ FROM debian:stretch-slim as builder +ARG ARCH RUN set -eux \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ ca-certificates \ curl \ - dpkg-dev \ && rm -rf /var/lib/apt/lists/* RUN set -eux \ && URL="$( \ curl -sS --fail https://ngrok.com/download \ - | grep -Eo "http(s)?://.+ngrok-stable-linux-$(dpkg-architecture --query DEB_BUILD_ARCH_CPU)\.tgz" \ + | grep -Eo "http(s)?://.+ngrok-stable-${ARCH}\.tgz" \ | head -1 \ )" \ && curl -sS --fail -o /tmp/ngrok.tgz "${URL}" \ diff --git a/Makefile b/Makefile index 98e65d3..859c16f 100644 --- a/Makefile +++ b/Makefile @@ -69,9 +69,11 @@ help: # Docker Targets # ------------------------------------------------------------------------------------------------- .PHONY: build +build: ARGS=--build-arg ARCH=$(subst /,-,$(ARCH)) build: docker-arch-build .PHONY: rebuild +build: ARGS=--build-arg ARCH=$(subst /,-,$(ARCH)) rebuild: docker-arch-rebuild .PHONY: push From 7aebac9bdb8844eaeee1302b7cebb54429bb9d4f Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 21:29:29 +0100 Subject: [PATCH 6/7] Fix rebuild target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 859c16f..1901975 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ build: ARGS=--build-arg ARCH=$(subst /,-,$(ARCH)) build: docker-arch-build .PHONY: rebuild -build: ARGS=--build-arg ARCH=$(subst /,-,$(ARCH)) +rebuild: ARGS=--build-arg ARCH=$(subst /,-,$(ARCH)) rebuild: docker-arch-rebuild .PHONY: push From 1a7955e1206ddf688e195766596f400d308c0a90 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 23 Mar 2022 21:34:55 +0100 Subject: [PATCH 7/7] Fix CI --- .github/workflows/params.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index 3b5eb1b..e24ef6a 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -15,7 +15,7 @@ env: { "NAME": "ngrok", "VERSION": ["2"], - "FLAVOUR": ["latest", "stretch"], + "FLAVOUR": ["latest", "stretch", "alpine"], "ARCH": ["linux/amd64", "linux/386", "linux/arm64"] } ] diff --git a/README.md b/README.md index e20c4be..097254c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![](https://images.microbadger.com/badges/image/devilbox/ngrok.svg)](https://microbadger.com/images/devilbox/ngrok "ngrok") [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) -**Available Architectures:** `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` +**Available Architectures:** `amd64`, `i386`, `arm64` | Docker Hub | Upstream Project | |------------|------------------|