From bbbcf271fe1c449a4a3b175dddf93c9366613f19 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 May 2021 15:21:56 +0200 Subject: [PATCH 01/33] remove otp token from login page, depending on Setting --- powerdnsadmin/templates/login.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/powerdnsadmin/templates/login.html b/powerdnsadmin/templates/login.html index ffa57a9..6352caa 100644 --- a/powerdnsadmin/templates/login.html +++ b/powerdnsadmin/templates/login.html @@ -46,9 +46,11 @@ data-error="Please input your password" required {% if password %}value="{{ password }}" {% endif %}> + {% if SETTING.get('otp_token_enabled') %}
+ {% endif %} {% if SETTING.get('ldap_enabled') and SETTING.get('local_db_enabled') %}
From 92bad7b11c190b57b1d793095469f82b48446f39 Mon Sep 17 00:00:00 2001 From: Steffen Schwebel Date: Tue, 1 Jun 2021 14:02:01 +0200 Subject: [PATCH 08/33] add environment to cron --- docker/Dockerfile.BackgroundJob | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile.BackgroundJob b/docker/Dockerfile.BackgroundJob index c8b6186..bf0bf5e 100644 --- a/docker/Dockerfile.BackgroundJob +++ b/docker/Dockerfile.BackgroundJob @@ -113,7 +113,7 @@ RUN mkdir /etc/services.d/gunicorn && \ # Create service script for cron RUN mkdir /etc/services.d/cron && \ - echo $'#!/usr/bin/execlineb -P\ncrond -f\n' > /etc/services.d/cron/run && \ + echo $'#!/usr/bin/execlineb -P\nwith-contenv\ncrond -f\n' > /etc/services.d/cron/run && \ chmod +x /etc/services.d/cron/run # Add crontab entries From c13dd2d83559dcdca30abc79697ab9f7fed083d4 Mon Sep 17 00:00:00 2001 From: Steffen Schwebel Date: Tue, 1 Jun 2021 16:15:31 +0200 Subject: [PATCH 09/33] add 'custom_css' setting to model; check for 'custom_css' in template; create custom css dir in dockerfile --- docker/Dockerfile.BackgroundJob | 2 ++ powerdnsadmin/models/setting.py | 1 + powerdnsadmin/templates/login.html | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile.BackgroundJob b/docker/Dockerfile.BackgroundJob index bf0bf5e..4904270 100644 --- a/docker/Dockerfile.BackgroundJob +++ b/docker/Dockerfile.BackgroundJob @@ -94,6 +94,8 @@ RUN apk add --no-cache mariadb-connector-c postgresql-client py3-gunicorn py3-ps COPY --from=builder /usr/bin/flask /usr/bin/ COPY --from=builder /usr/lib/python3.8/site-packages /usr/lib/python3.8/site-packages/ COPY --from=builder --chown=root:${USER} /app /app/ +# Create directory for custom css +RUN mkdir /app/powerdnsadmin/static/custom COPY ./docker/entrypoint.sh /usr/bin/ WORKDIR /app diff --git a/powerdnsadmin/models/setting.py b/powerdnsadmin/models/setting.py index 0d3a575..5fea755 100644 --- a/powerdnsadmin/models/setting.py +++ b/powerdnsadmin/models/setting.py @@ -181,6 +181,7 @@ class Setting(db.Model): }, 'ttl_options': '1 minute,5 minutes,30 minutes,60 minutes,24 hours', 'otp_field_enabled': True, + 'custom_css': '', } def __init__(self, id=None, name=None, value=None): diff --git a/powerdnsadmin/templates/login.html b/powerdnsadmin/templates/login.html index 1d597fd..4ddf21f 100644 --- a/powerdnsadmin/templates/login.html +++ b/powerdnsadmin/templates/login.html @@ -11,7 +11,9 @@ {% assets "css_login" -%} {%- endassets %} - +{% if SETTING.get('custom_css') %} + +{% endif %} From 0505b934a10b46fe2cf7c1e280a0db9ab52b54dd Mon Sep 17 00:00:00 2001 From: Steffen Schwebel Date: Wed, 2 Jun 2021 09:39:39 +0200 Subject: [PATCH 12/33] remove unrelated files and changes as best as possible --- docker/Dockerfile.BackgroundJob | 127 -------------------------------- powerdnsadmin/lib/utils.py | 7 -- update_accounts.py | 6 +- update_zones.py | 5 +- 4 files changed, 5 insertions(+), 140 deletions(-) delete mode 100644 docker/Dockerfile.BackgroundJob diff --git a/docker/Dockerfile.BackgroundJob b/docker/Dockerfile.BackgroundJob deleted file mode 100644 index 4904270..0000000 --- a/docker/Dockerfile.BackgroundJob +++ /dev/null @@ -1,127 +0,0 @@ -FROM alpine:3.13 AS builder -LABEL maintainer="k@ndk.name" - -ARG BUILD_DEPENDENCIES="build-base \ - libffi-dev \ - libxml2-dev \ - mariadb-connector-c-dev \ - openldap-dev \ - python3-dev \ - xmlsec-dev \ - yarn \ - cargo" - - -ENV LC_ALL=en_US.UTF-8 \ - LANG=en_US.UTF-8 \ - LANGUAGE=en_US.UTF-8 \ - FLASK_APP=/build/powerdnsadmin/__init__.py - -# Get dependencies -# py3-pip should not belong to BUILD_DEPENDENCIES. Otherwise, when we remove -# them with "apk del" at the end of build stage, the python requests module -# will be removed as well - (Tested with alpine:3.12 and python 3.8.5). -RUN apk add --no-cache ${BUILD_DEPENDENCIES} && \ - apk add --no-cache py3-pip - -WORKDIR /build - -# We copy just the requirements.txt first to leverage Docker cache -COPY ./requirements.txt /build/requirements.txt - -# Get application dependencies -RUN pip install --upgrade pip && \ - pip install -r requirements.txt - -# Add sources -COPY . /build - -# Prepare assets -RUN yarn install --pure-lockfile --production && \ - yarn cache clean && \ - sed -i -r -e "s|'cssmin',\s?'cssrewrite'|'cssmin'|g" /build/powerdnsadmin/assets.py && \ - flask assets build - -RUN mv /build/powerdnsadmin/static /tmp/static && \ - mkdir /build/powerdnsadmin/static && \ - cp -r /tmp/static/generated /build/powerdnsadmin/static && \ - cp -r /tmp/static/assets /build/powerdnsadmin/static && \ - cp -r /tmp/static/img /build/powerdnsadmin/static && \ - find /tmp/static/node_modules -name 'fonts' -exec cp -r {} /build/powerdnsadmin/static \; && \ - find /tmp/static/node_modules/icheck/skins/square -name '*.png' -exec cp {} /build/powerdnsadmin/static/generated \; - -RUN { \ - echo "from flask_assets import Environment"; \ - echo "assets = Environment()"; \ - echo "assets.register('js_login', 'generated/login.js')"; \ - echo "assets.register('js_validation', 'generated/validation.js')"; \ - echo "assets.register('css_login', 'generated/login.css')"; \ - echo "assets.register('js_main', 'generated/main.js')"; \ - echo "assets.register('css_main', 'generated/main.css')"; \ - } > /build/powerdnsadmin/assets.py - -# Move application -RUN mkdir -p /app && \ - cp -r /build/migrations/ /build/powerdnsadmin/ /build/run.py /app && \ - mkdir -p /app/configs && \ - cp -r /build/configs/docker_config.py /app/configs -# Also copy update scripts -RUN cp /build/update_accounts.py /build/update_zones.py /app/ - -# Cleanup -RUN pip install pip-autoremove && \ - pip-autoremove cssmin -y && \ - pip-autoremove jsmin -y && \ - pip-autoremove pytest -y -L packaging && \ - pip uninstall -y pip-autoremove && \ - apk del ${BUILD_DEPENDENCIES} - -# Build image -FROM alpine:3.13 -ARG S6_VERSION=v2.2.0.3 - -ENV FLASK_APP=/app/powerdnsadmin/__init__.py \ - USER=pda - -RUN apk add --no-cache mariadb-connector-c postgresql-client py3-gunicorn py3-psycopg2 xmlsec tzdata libcap apk-cron && \ - addgroup -S ${USER} && \ - adduser -S -D -G ${USER} ${USER} && \ - mkdir /data && \ - chown ${USER}:${USER} /data && \ - setcap cap_net_bind_service=+ep $(readlink -f /usr/bin/python3) && \ - apk del libcap - -COPY --from=builder /usr/bin/flask /usr/bin/ -COPY --from=builder /usr/lib/python3.8/site-packages /usr/lib/python3.8/site-packages/ -COPY --from=builder --chown=root:${USER} /app /app/ -# Create directory for custom css -RUN mkdir /app/powerdnsadmin/static/custom -COPY ./docker/entrypoint.sh /usr/bin/ - -WORKDIR /app -RUN chown ${USER}:${USER} ./configs /app && \ - cat ./powerdnsadmin/default_config.py ./configs/docker_config.py > ./powerdnsadmin/docker_config.py - -# Add s6 overlay, so we can manage multiple processes -ADD https://github.com/just-containers/s6-overlay/releases/download/$S6_VERSION/s6-overlay-amd64-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer / - -# Create service script for gunicorn -RUN mkdir /etc/services.d/gunicorn && \ - echo $'#!/usr/bin/execlineb -P\nwith-contenv\n' > /etc/services.d/gunicorn/run && \ - echo "s6-setuidgid $USER" >> /etc/services.d/gunicorn/run && \ - echo $'\n/usr/bin/entrypoint.sh gunicorn powerdnsadmin:create_app()' >> /etc/services.d/gunicorn/run && \ - chmod +x /etc/services.d/gunicorn/run - -# Create service script for cron -RUN mkdir /etc/services.d/cron && \ - echo $'#!/usr/bin/execlineb -P\nwith-contenv\ncrond -f\n' > /etc/services.d/cron/run && \ - chmod +x /etc/services.d/cron/run - -# Add crontab entries -RUN echo "*/5 * * * * python3 /app/update_zones.py" >> /etc/crontabs/$USER && \ - echo "*/5 * * * * python3 /app/update_accounts.py" >> /etc/crontabs/$USER - -EXPOSE 80/tcp -HEALTHCHECK CMD ["wget","--output-document=-","--quiet","--tries=1","http://127.0.0.1/"] -ENTRYPOINT ["/init"] diff --git a/powerdnsadmin/lib/utils.py b/powerdnsadmin/lib/utils.py index d086e81..d7f20a4 100644 --- a/powerdnsadmin/lib/utils.py +++ b/powerdnsadmin/lib/utils.py @@ -104,13 +104,6 @@ def fetch_json(remote_url, data = None try: data = json.loads(r.content.decode('utf-8')) - except UnicodeDecodeError: - # If the decoding fails, switch to slower but probably working .json() - try: - logging.warning("UTF-8 content.decode failed, switching to slower .json method") - data = r.json() - except Exception as e: - raise e except Exception as e: raise RuntimeError( 'Error while loading JSON data from {0}'.format(remote_url)) from e diff --git a/update_accounts.py b/update_accounts.py index 4c5f04e..0578ce0 100644 --- a/update_accounts.py +++ b/update_accounts.py @@ -25,9 +25,7 @@ with app.app_context(): ### Check if bg_domain_updates is set to true if not status: - app.logger.debug('"bg_domain_updates" is disabled, exiting') - sys.exit(0) + app.logger.error('Please turn on "bg_domain_updates" setting to run this job.') + sys.exit(1) - ### Start the update process - app.logger.info('Update accounts from nameserver API') Account().update() diff --git a/update_zones.py b/update_zones.py index 79fc19a..5da542f 100644 --- a/update_zones.py +++ b/update_zones.py @@ -16,6 +16,7 @@ import logging from powerdnsadmin import create_app from powerdnsadmin.models.domain import Domain from powerdnsadmin.models.setting import Setting + app = create_app() app.logger.setLevel(logging.INFO) @@ -24,8 +25,8 @@ with app.app_context(): ### Check if bg_domain_updates is set to true if not status: - app.logger.debug('"bg_domain_updates" is disabled, exiting') - sys.exit(0) + app.logger.error('Please turn on "bg_domain_updates" setting to run this job.') + sys.exit(1) ### Start the update process app.logger.info('Update domains from nameserver API') From fd933f8dbc6ec4ebac0ee6554901d4866096c9ba Mon Sep 17 00:00:00 2001 From: Steffen Schwebel Date: Wed, 2 Jun 2021 09:41:08 +0200 Subject: [PATCH 13/33] remove unrelated files and changes as best as possible --- powerdnsadmin/models/setting.py | 1 - powerdnsadmin/routes/admin.py | 2 +- powerdnsadmin/templates/login.html | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/powerdnsadmin/models/setting.py b/powerdnsadmin/models/setting.py index 5fea755..acb3bc2 100644 --- a/powerdnsadmin/models/setting.py +++ b/powerdnsadmin/models/setting.py @@ -180,7 +180,6 @@ class Setting(db.Model): 'URI': False }, 'ttl_options': '1 minute,5 minutes,30 minutes,60 minutes,24 hours', - 'otp_field_enabled': True, 'custom_css': '', } diff --git a/powerdnsadmin/routes/admin.py b/powerdnsadmin/routes/admin.py index 90750a1..81c888b 100644 --- a/powerdnsadmin/routes/admin.py +++ b/powerdnsadmin/routes/admin.py @@ -642,7 +642,7 @@ def setting_basic(): 'pretty_ipv6_ptr', 'dnssec_admins_only', 'allow_user_create_domain', 'allow_user_view_history', 'bg_domain_updates', 'site_name', 'session_timeout', 'warn_session_timeout', 'ttl_options', - 'pdns_api_timeout', 'verify_ssl_connections', 'verify_user_email', 'otp_field_enabled','custom_css' + 'pdns_api_timeout', 'verify_ssl_connections', 'verify_user_email', 'custom_css' ] return render_template('admin_setting_basic.html', settings=settings) diff --git a/powerdnsadmin/templates/login.html b/powerdnsadmin/templates/login.html index dcf96cf..6fac9d4 100644 --- a/powerdnsadmin/templates/login.html +++ b/powerdnsadmin/templates/login.html @@ -48,11 +48,9 @@ data-error="Please input your password" required {% if password %}value="{{ password }}" {% endif %}> - {% if SETTING.get('otp_field_enabled') %}
- {% endif %} {% if SETTING.get('ldap_enabled') and SETTING.get('local_db_enabled') %}
+
+
+ +
+ + + + +
+ + +
+
+
+

Help with removing a new domain

+
+
+
+
Domain name
+
Select domain you wish to remove from DNS.
+
+

Find more details at https://docs.powerdns.com/md/ +

+
+
+
+ + +{% endblock %} +{% block extrascripts %} + +{% endblock %} + +{% block modals %} + +{% endblock %} From f96103db7946255280a1a7cdb1ab65a5e9dafdab Mon Sep 17 00:00:00 2001 From: Hidde Date: Sat, 30 Oct 2021 21:24:16 +0200 Subject: [PATCH 21/33] Replace [ZONE] placeholder with domain_name (#960) --- powerdnsadmin/models/record.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/powerdnsadmin/models/record.py b/powerdnsadmin/models/record.py index f8fceff..e2e2b5a 100644 --- a/powerdnsadmin/models/record.py +++ b/powerdnsadmin/models/record.py @@ -165,6 +165,8 @@ class Record(object): for record in submitted_records: # Format the record name # + # Translate template placeholders into proper record data + record['record_data'] = record['record_data'].replace('[ZONE]', domain_name) # Translate record name into punycode (IDN) as that's the only way # to convey non-ascii records to the dns server record['record_name'] = record['record_name'].encode('idna').decode() From c246775ffe4a65592a0aef83844bd36dedff4613 Mon Sep 17 00:00:00 2001 From: RGanor <44501230+RGanor@users.noreply.github.com> Date: Sat, 30 Oct 2021 22:26:46 +0300 Subject: [PATCH 22/33] bg_domain button for operators and higher (#993) --- powerdnsadmin/routes/dashboard.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/powerdnsadmin/routes/dashboard.py b/powerdnsadmin/routes/dashboard.py index 457c415..c953ec7 100644 --- a/powerdnsadmin/routes/dashboard.py +++ b/powerdnsadmin/routes/dashboard.py @@ -3,6 +3,7 @@ from flask import Blueprint, render_template, url_for, current_app, request, jso from flask_login import login_required, current_user, login_manager from sqlalchemy import not_ +from ..decorators import operator_role_required from ..lib.utils import customBoxes from ..models.user import User, Anonymous from ..models.account import Account @@ -150,6 +151,10 @@ def dashboard(): else: current_app.logger.info('Updating domains in background...') + show_bg_domain_button = BG_DOMAIN_UPDATE + if BG_DOMAIN_UPDATE and current_user.role.name not in ['Administrator', 'Operator']: + show_bg_domain_button = False + # Stats for dashboard domain_count = 0 history_number = 0 @@ -198,12 +203,13 @@ def dashboard(): history_number=history_number, uptime=uptime, histories=history, - show_bg_domain_button=BG_DOMAIN_UPDATE, + show_bg_domain_button=show_bg_domain_button, pdns_version=Setting().get('pdns_version')) @dashboard_bp.route('/domains-updater', methods=['GET', 'POST']) @login_required +@operator_role_required def domains_updater(): current_app.logger.debug('Update domains in background') d = Domain().update() From b8ee91ab9ab503abdb7c446d92b3fac33e83e587 Mon Sep 17 00:00:00 2001 From: jbe-dw <50663045+jbe-dw@users.noreply.github.com> Date: Sat, 30 Oct 2021 21:28:36 +0200 Subject: [PATCH 23/33] fix: Accounts API is broken (#996) --- powerdnsadmin/lib/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/lib/schema.py b/powerdnsadmin/lib/schema.py index daee29a..78d8369 100644 --- a/powerdnsadmin/lib/schema.py +++ b/powerdnsadmin/lib/schema.py @@ -47,7 +47,7 @@ class UserDetailedSchema(Schema): lastname = fields.String() email = fields.String() role = fields.Embed(schema=RoleSchema) - accounts = fields.Embed(schema=AccountSummarySchema) + accounts = fields.Embed(schema=AccountSummarySchema, many=True) class AccountSchema(Schema): id = fields.Integer() From 46e51f16cbaf8c0e3d826a64cfa886b23aaf615a Mon Sep 17 00:00:00 2001 From: Andreas Dirnberger Date: Sat, 30 Oct 2021 21:29:23 +0200 Subject: [PATCH 24/33] Remove unnecessary build step (#1003) The builder image does not need to cleanup itself, the whole purpose of it is to be dropped after the final artifacts are copied out. --- docker/Dockerfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index b44d749..5296e02 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -65,14 +65,6 @@ RUN mkdir -p /app && \ mkdir -p /app/configs && \ cp -r /build/configs/docker_config.py /app/configs -# Cleanup -RUN pip install pip-autoremove && \ - pip-autoremove cssmin -y && \ - pip-autoremove jsmin -y && \ - pip-autoremove pytest -y -L packaging && \ - pip uninstall -y pip-autoremove && \ - apk del ${BUILD_DEPENDENCIES} - # Build image FROM alpine:3.13 From ba2423d6f549fa587bcbd2a10e66d043eb7851c5 Mon Sep 17 00:00:00 2001 From: steschuser Date: Sat, 30 Oct 2021 21:29:55 +0200 Subject: [PATCH 25/33] fix if condition in pretty_domain_name (#1008) --- powerdnsadmin/lib/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/lib/utils.py b/powerdnsadmin/lib/utils.py index d086e81..951f750 100644 --- a/powerdnsadmin/lib/utils.py +++ b/powerdnsadmin/lib/utils.py @@ -246,7 +246,7 @@ def pretty_domain_name(value): """ if isinstance(value, str): if value.startswith('xn--') \ - or value.find('.xn--'): + or value.find('.xn--') != -1: try: return value.encode().decode('idna') except: From 0e655c1357ed18578a6d934509eed9892631039c Mon Sep 17 00:00:00 2001 From: zoeller-freinet <86965592+zoeller-freinet@users.noreply.github.com> Date: Sat, 30 Oct 2021 21:30:26 +0200 Subject: [PATCH 26/33] user_profile tpl: set email input type attr to "email" (#1020) It is then consistent with the email address input elements declared in admin_edit_account.html, admin_edit_user.html and register.html. --- powerdnsadmin/templates/user_profile.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerdnsadmin/templates/user_profile.html b/powerdnsadmin/templates/user_profile.html index 02251ad..a13d3d3 100644 --- a/powerdnsadmin/templates/user_profile.html +++ b/powerdnsadmin/templates/user_profile.html @@ -51,7 +51,7 @@ {% if session['authentication_type'] != 'LOCAL' %}disabled{% endif %}>
- E-mail
{% if session['authentication_type'] == 'LOCAL' %} From 1c9ca605080546d4fd7106db7745f4d9c0a8993e Mon Sep 17 00:00:00 2001 From: jbe-dw <50663045+jbe-dw@users.noreply.github.com> Date: Sat, 30 Oct 2021 21:30:53 +0200 Subject: [PATCH 27/33] fix: jsmin 2.2.2 no longer available. Use 3.0.0 (#1021) --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 51184d3..5e97a12 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ python3-saml pyOpenSSL==19.1.0 pytz==2020.1 cssmin==0.2.0 -jsmin==2.2.2 +jsmin==3.0.0 Authlib==0.15 Flask-SeaSurf==0.2.2 bravado-core==5.17.0 @@ -27,4 +27,4 @@ pytimeparse==1.1.8 PyYAML==5.4 Flask-SSLify==0.1.5 Flask-Mail==0.9.1 -flask-session==0.3.2 \ No newline at end of file +flask-session==0.3.2 From d7ae34ed536e2d2f668dc88126360f727a690ddf Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 31 Oct 2021 13:08:22 +0100 Subject: [PATCH 28/33] Update CI Signed-off-by: Khanh Ngo --- .gitlab-ci.yml | 4 ++++ .travis.yml | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 .gitlab-ci.yml delete mode 100644 .travis.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d32707a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,4 @@ +include: + - project: 'powerdns-admin/ci' + ref: main + file: '.build-docker-images.yml' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 311f17c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: minimal -script: - - docker-compose -f docker-compose-test.yml up --exit-code-from powerdns-admin --abort-on-container-exit -services: - - docker From ee9f568a8d9b421c7276f382a7043e8b71324d9a Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 31 Oct 2021 13:16:42 +0100 Subject: [PATCH 29/33] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 67f5e2e..e924bb0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # PowerDNS-Admin A PowerDNS web interface with advanced features. -[![Build Status](https://travis-ci.org/ngoduykhanh/PowerDNS-Admin.svg?branch=master)](https://travis-ci.org/ngoduykhanh/PowerDNS-Admin) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/ngoduykhanh/PowerDNS-Admin.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ngoduykhanh/PowerDNS-Admin/context:python) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/ngoduykhanh/PowerDNS-Admin.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ngoduykhanh/PowerDNS-Admin/context:javascript) From 4f8a547d473cc93ee8ac6d965c89c6cb68329d95 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 31 Oct 2021 14:23:49 +0100 Subject: [PATCH 30/33] Update CI Signed-off-by: Khanh Ngo --- .github/workflows/build-and-publish.yml | 52 +++++++++++++++++++++++++ .gitlab-ci.yml | 4 -- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-and-publish.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..c30415d --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,52 @@ +on: + push: + branches: + - 'master' + tags: + - 'v*.*.*' + +jobs: + build-and-push-docker-image: + name: Build Docker image and push to repositories + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ngoduykhanh/powerdns-admin + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build latest image + uses: docker/build-push-action@v2 + if: github.ref == 'refs/heads/master' + with: + context: . + push: true + tags: ngoduykhanh/powerdns-admin:latest + + - name: Build release image + uses: docker/build-push-action@v2 + if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }} + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d32707a..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,4 +0,0 @@ -include: - - project: 'powerdns-admin/ci' - ref: main - file: '.build-docker-images.yml' From 924537b468d24bbd47e15bebbef65c9ead452094 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 31 Oct 2021 14:25:22 +0100 Subject: [PATCH 31/33] Update CI Signed-off-by: Khanh Ngo --- .github/workflows/build-and-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index c30415d..e108c20 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -39,7 +39,7 @@ jobs: uses: docker/build-push-action@v2 if: github.ref == 'refs/heads/master' with: - context: . + context: ./docker push: true tags: ngoduykhanh/powerdns-admin:latest @@ -47,6 +47,6 @@ jobs: uses: docker/build-push-action@v2 if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }} with: - context: . + context: ./docker push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} From c49df09ac8ecc24b8f81c1c1f9e9ac1020c3c991 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 31 Oct 2021 14:31:14 +0100 Subject: [PATCH 32/33] Update CI Signed-off-by: Khanh Ngo --- .github/workflows/build-and-publish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index e108c20..75c4644 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -25,6 +25,9 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 @@ -48,5 +51,5 @@ jobs: if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }} with: context: ./docker - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} From 1662a812ba0a0452c6644130c1f0d4a6a937a232 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Sun, 31 Oct 2021 14:34:35 +0100 Subject: [PATCH 33/33] Update CI Signed-off-by: Khanh Ngo --- .github/workflows/build-and-publish.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 75c4644..46e92ef 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -25,9 +25,6 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 @@ -42,7 +39,8 @@ jobs: uses: docker/build-push-action@v2 if: github.ref == 'refs/heads/master' with: - context: ./docker + context: ./ + file: ./docker/Dockerfile push: true tags: ngoduykhanh/powerdns-admin:latest @@ -50,6 +48,7 @@ jobs: uses: docker/build-push-action@v2 if: ${{ github.event_name == 'create' && github.event.ref_type == 'tag' }} with: - context: ./docker + context: ./ + file: ./docker/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }}