From 52eebdd9256a87b136fe212678496ed59d0c3362 Mon Sep 17 00:00:00 2001 From: OLeonardoRodrigues Date: Fri, 29 Jul 2022 02:29:24 -0300 Subject: [PATCH] major overwrite --- .repo-keeper => .keypr | 2 +- Dockerfile | 45 +++++++++++++++++-------------------- action.yml | 8 +++---- scripts/docker_run_local.sh | 11 +++++++++ src/auth.py | 2 +- src/parse_config.py | 2 +- 6 files changed, 39 insertions(+), 31 deletions(-) rename .repo-keeper => .keypr (95%) create mode 100644 scripts/docker_run_local.sh diff --git a/.repo-keeper b/.keypr similarity index 95% rename from .repo-keeper rename to .keypr index b636fea..9afb8f0 100644 --- a/.repo-keeper +++ b/.keypr @@ -2,7 +2,7 @@ topic1 topic2 topic3 -topic4 +topic5 [options] default-branch = main diff --git a/Dockerfile b/Dockerfile index 387fcbe..113920f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,13 @@ -FROM python:3.9-slim-buster +FROM python:3.9.13-alpine3.16 AS base -LABEL org.opencontainers.image.title="Repo Keeper" \ +LABEL org.opencontainers.image.title="Keypr" \ org.opencontainers.image.description="Configuration Keeper for GitHub Repositories." \ - org.opencontainers.image.url="https://github.com/OLeonardoRodrigues/repo-keeper/blob/main/README.md" \ - org.opencontainers.image.documentation="https://github.com/OLeonardoRodrigues/repo-keeper/wiki" \ - org.opencontainers.image.source="https://github.com/OLeonardoRodrigues/repo-keeper" \ - org.opencontainers.image.licenses="GPL-3.0-only" \ - org.opencontainers.image.vendor="Leonardo Rodrigues de Oliveira - OLeonardoRodrigues" \ - org.opencontainers.image.base.name="registry.hub.docker.com/python/python:3.9-slim-buster" \ - org.opencontainers.image.base.digest="sha256:a32a3204b2b44f3e7e699e5b4af1a5784b6a9b8a4f4446dbb8a3aa65375a8d7d" + org.opencontainers.image.url="https://github.com/fr-platform/keypr/blob/main/README.md" \ + org.opencontainers.image.documentation="https://github.com/fr-platform/keypr/wiki" \ + org.opencontainers.image.source="https://github.com/fr-platform/keypr" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.vendor="Fr Platform" \ + org.opencontainers.image.base.name="registry.hub.docker.com/python/python:3.9.13-alpine3.16" WORKDIR /app @@ -16,26 +15,24 @@ ENV PYTHONPATH /app ENV GH_CONFIG_DIR /app/gh_config -RUN useradd -m python - -RUN mkdir /app/gh_config \ - && chown -R python:python /app/gh_config \ - && chmod +w /app/gh_config +RUN addgroup -S python \ + && adduser -S python -G python \ + && apk update \ + && apk add --no-cache --virtual .build-deps curl \ + && apk add --no-cache git github-cli \ + && apk del --purge .build-deps \ + && mkdir --mode=777 /app/gh_config \ + && chown --recursive python:python /app/gh_config COPY --chown=python:python requirements.txt ./ -RUN pip3 install -r requirements.txt +RUN pip install --no-cache-dir --no-color --no-python-version-warning --disable-pip-version-check --requirement requirements.txt \ + && rm -f requirement.txt -RUN apt-get update \ - && apt-get upgrade -y \ - && apt-get install curl -y \ - && apt-get install git -y \ - && curl -L https://github.com/cli/cli/releases/download/v2.7.0/gh_2.7.0_linux_amd64.deb \ - > gh_2.7.0_linux_amd64.deb \ - && dpkg -i ./gh_2.7.0_linux_amd64.deb +FROM base AS deploy -COPY --chown=python:python src repo_keeper +COPY --chown=python:python src keypr USER python -CMD [ "python3.9", "-m" , "repo_keeper"] +CMD [ "python", "-m" , "keypr"] diff --git a/action.yml b/action.yml index 134d502..27e3237 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: 'Repo Keeper' -description: 'Runs Repo Keeper' +name: 'Keypr' +description: 'Runs Keypr' author: 'OLeonardoRodrigues' branding: @@ -14,11 +14,11 @@ inputs: config-file: description: 'Configuration File Name or Path.' required: false - default: '.repo-keeper' + default: '.keypr' runs: using: 'docker' - image: 'docker://ghcr.io/oleonardorodrigues/repo-keeper:latest' + image: 'docker://ghcr.io/oleonardorodrigues/keypr:latest' env: GH_PAT: ${{ inputs.github-pat }} CONFIG_FILE: ${{ inputs.config-file }} diff --git a/scripts/docker_run_local.sh b/scripts/docker_run_local.sh new file mode 100644 index 0000000..6e48eb6 --- /dev/null +++ b/scripts/docker_run_local.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +sudo docker rmi --force keypr:local + +sudo docker container prune --force + +sudo docker build . --tag keypr:local --no-cache --progress plain + +sudo docker run --detach --name keypr keypr:local + +sudo docker images --all --format '{{.Size}}' keypr:local diff --git a/src/auth.py b/src/auth.py index 8431baf..786504b 100644 --- a/src/auth.py +++ b/src/auth.py @@ -3,6 +3,6 @@ def auth(): print('Authenticating to GitHub.') try: - system(f"echo {environ.get('GH_PAT')} | gh auth login --git-protocol https --hostname GitHub.com --with-token") + system(f"echo {environ.get('GH_PAT')} | gh auth login --git-protocol https --hostname GitHub.com --with-token && gh auth status") except: print("Failure authenticating to GitHub.") diff --git a/src/parse_config.py b/src/parse_config.py index 2571456..c45ab8d 100644 --- a/src/parse_config.py +++ b/src/parse_config.py @@ -5,7 +5,7 @@ def parse_config(): try: filename = path.abspath(environ.get('CONFIG_FILE')) except: - filename = '.repo-keeper' + filename = '.keypr' topics = parse_topics(filename=filename) options = parse_options(filename=filename)