From 27a96511b032e6ad0f5dcdc1ff751c25a621bff9 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 28 Sep 2019 19:25:17 +0200 Subject: [PATCH] initial commit --- .drone.jsonnet | 126 +++++++++++++++++++++++++++++++++++ .drone.yml | 116 ++++++++++++++++++++++++++++++++ Dockerfile.linux.amd64 | 35 ++++++++++ manifest.tmpl | 12 ++++ overlay/etc/nginx/nginx.conf | 24 +++++++ overlay/etc/nginx/vhost.conf | 16 +++++ 6 files changed, 329 insertions(+) create mode 100644 .drone.jsonnet create mode 100644 .drone.yml create mode 100644 Dockerfile.linux.amd64 create mode 100644 manifest.tmpl create mode 100644 overlay/etc/nginx/nginx.conf create mode 100644 overlay/etc/nginx/vhost.conf diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..fb96f89 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,126 @@ +local PipelineBuild(os='linux', arch='amd64') = { + local tag = os + '-' + arch, + local version_tag = os + '-' + arch, + local file_suffix = std.strReplace(version_tag, '-', '.'), + kind: "pipeline", + name: version_tag, + platform: { + os: os, + arch: arch, + }, + steps: [ + { + name: 'dryrun', + image: 'plugins/docker:' + tag, + pull: 'always', + settings: { + dry_run: true, + tags: version_tag, + dockerfile: './Dockerfile.' + file_suffix, + repo: 'xoxys/nginx', + username: { from_secret: "docker_username" }, + password: { from_secret: "docker_password" }, + }, + }, + { + name: 'publish', + image: 'plugins/docker:' + tag, + pull: 'always', + settings: { + auto_tag: true, + auto_tag_suffix: version_tag, + dockerfile: './Dockerfile.' + file_suffix, + repo: 'xoxys/nginx', + username: { from_secret: "docker_username" }, + password: { from_secret: "docker_password" }, + }, + when: { + ref: [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + }, + ], +}; + +local PipelineNotifications(depends_on=[]) = { + kind: "pipeline", + name: "notifications", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + { + image: "plugins/manifest", + name: "manifest", + pull: "always", + settings: { + ignore_missing: true, + username: { from_secret: "docker_username" }, + password: { from_secret: "docker_password" }, + spec: "./manifest.tmpl", + }, + when: { + ref: [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + }, + { + name: "readme", + image: "sheogorath/readme-to-dockerhub", + pull: "always", + environment: { + DOCKERHUB_USERNAME: { from_secret: "docker_username" }, + DOCKERHUB_PASSWORD: { from_secret: "docker_password" }, + DOCKERHUB_REPO_PREFIX: "xoxys", + DOCKERHUB_REPO_NAME: "nginx", + README_PATH: "README.md", + SHORT_DESCRIPTION: "nginx - Rootless nginx container" + }, + when: { + ref: [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + }, + { + name: "microbadger", + image: "plugins/webhook", + pull: "always", + settings: { + urls: { from_secret: "microbadger_url" }, + }, + }, + { + image: "plugins/matrix", + name: "matrix", + pull: 'always', + settings: { + homeserver: "https://matrix.rknet.org", + roomid: "MtidqQXWWAtQcByBhH:rknet.org", + template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}", + username: { from_secret: "matrix_username" }, + password: { from_secret: "matrix_password" }, + }, + when: { + status: [ "success", "failure" ], + }, + }, + ], + trigger: { + status: [ "success", "failure" ], + }, + depends_on: depends_on, +}; + +[ + PipelineBuild(os='linux', arch='amd64'), + PipelineNotifications(depends_on=[ + "linux-amd64", + ]) +] diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..2b3b56d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,116 @@ +--- +kind: pipeline +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: +- name: dryrun + pull: always + image: plugins/docker:linux-amd64 + settings: + dockerfile: ./Dockerfile.linux.amd64 + dry_run: true + password: + from_secret: docker_password + repo: xoxys/nginx + tags: linux-amd64 + username: + from_secret: docker_username + +- name: publish + pull: always + image: plugins/docker:linux-amd64 + settings: + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: ./Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: xoxys/nginx + username: + from_secret: docker_username + when: + ref: + - refs/heads/master + - "refs/tags/**" + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +steps: +- name: manifest + pull: always + image: plugins/manifest + settings: + ignore_missing: true + password: + from_secret: docker_password + spec: ./manifest.tmpl + username: + from_secret: docker_username + when: + ref: + - refs/heads/master + - "refs/tags/**" + +- name: readme + pull: always + image: sheogorath/readme-to-dockerhub + environment: + DOCKERHUB_PASSWORD: + from_secret: docker_password + DOCKERHUB_REPO_NAME: nginx + DOCKERHUB_REPO_PREFIX: xoxys + DOCKERHUB_USERNAME: + from_secret: docker_username + README_PATH: README.md + SHORT_DESCRIPTION: nginx - Rootless nginx container + when: + ref: + - refs/heads/master + - "refs/tags/**" + +- name: microbadger + pull: always + image: plugins/webhook + settings: + urls: + from_secret: microbadger_url + +- name: matrix + pull: always + image: plugins/matrix + settings: + homeserver: https://matrix.rknet.org + password: + from_secret: matrix_password + roomid: MtidqQXWWAtQcByBhH:rknet.org + template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}" + username: + from_secret: matrix_username + when: + status: + - success + - failure + +trigger: + status: + - success + - failure + +depends_on: +- linux-amd64 + +--- +kind: signature +hmac: 5f8c33923414a6be0e1699e3df3cd4d58988403efffbc41d0c57f18ca54027b5 + +... diff --git a/Dockerfile.linux.amd64 b/Dockerfile.linux.amd64 new file mode 100644 index 0000000..def2bcf --- /dev/null +++ b/Dockerfile.linux.amd64 @@ -0,0 +1,35 @@ +FROM alpine:3.10 + +LABEL maintainer="Robert Kaussow " \ + org.label-schema.name="Nginx" \ + org.label-schema.version="1.2" \ + org.label-schema.vendor="Robert Kaussow" \ + org.label-schema.schema-version="1.0" + +RUN addgroup -g 101 -S nginx && \ + adduser -S -D -H -u 101 -h /var/www -s /sbin/nologin -G nginx -g nginx nginx && \ + apk --update add --virtual .build-deps curl && \ + apk --update --no-cache add nginx ca-certificates && \ + rm -rf /var/www/localhost && \ + rm -rf /etc/nginx/conf.d && \ + curl -SsL -o /usr/local/bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/v3.5.0/gomplate_linux-amd64-slim && \ + chmod 755 /usr/local/bin/gomplate && \ + touch /run/nginx.pid && \ + chown nginx /run/nginx.pid && \ + chown -R nginx /var/log/nginx && \ + mkdir -p /var/cache/nginx && \ + chown -R nginx /var/cache/nginx && \ + chmod -R 750 /var/cache/nginx && \ + chown -R nginx /var/www && \ + chmod -R 750 /var/www && \ + apk del .build-deps && \ + rm -rf /var/cache/apk/* && \ + rm -rf /tmp/* + +ADD overlay/ / + +EXPOSE 8080 + +STOPSIGNAL SIGTERM + +CMD ["nginx", "-g", "daemon off;"] diff --git a/manifest.tmpl b/manifest.tmpl new file mode 100644 index 0000000..7383e2b --- /dev/null +++ b/manifest.tmpl @@ -0,0 +1,12 @@ +image: xoxys/nginx:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - image: xoxys/nginx:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux diff --git a/overlay/etc/nginx/nginx.conf b/overlay/etc/nginx/nginx.conf new file mode 100644 index 0000000..2fe3efb --- /dev/null +++ b/overlay/etc/nginx/nginx.conf @@ -0,0 +1,24 @@ +worker_processes 1; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + server_tokens off; + access_log off; + error_log /dev/stderr; + + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + + include /etc/nginx/vhost.conf; +} diff --git a/overlay/etc/nginx/vhost.conf b/overlay/etc/nginx/vhost.conf new file mode 100644 index 0000000..6cdf91e --- /dev/null +++ b/overlay/etc/nginx/vhost.conf @@ -0,0 +1,16 @@ +server { + listen 8080; + server_name localhost; + + location / { + root /var/lib/nginx/html; + index index.html index.htm; + } + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/lib/nginx/html; + } +}