summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/docker-image.yml31
-rw-r--r--.github/workflows/python-publish.yml43
-rw-r--r--.github/workflows/release.yml72
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--docker/Dockerfile59
5 files changed, 106 insertions, 101 deletions
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
deleted file mode 100644
index 3889f7e5..00000000
--- a/.github/workflows/docker-image.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-# code created with help of the github documentation : https://docs.github.com/en/actions/guides/publishing-docker-images
-
-name: Docker Image CI
-
-on:
- push:
- branches: [master]
- pull_request:
- branches: [master]
- workflow_dispatch:
-
-jobs:
- docker:
- runs-on: ubuntu-latest
- steps:
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v1
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
- - name: Login to DockerHub
- uses: docker/login-action@v1
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_PASSWORD }}
- - name: Build and push
- id: docker_build
- uses: docker/build-push-action@v2
- with:
- file: docker/Dockerfile
- push: true
- tags: seccerts/sec-certs:latest
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
deleted file mode 100644
index 782ec7aa..00000000
--- a/.github/workflows/python-publish.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-# This workflow will upload a Python Package using Twine when a release is created
-# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
-
-name: Upload Python Package
-
-on:
- push:
- branches: [master]
- pull_request:
- branches: [master]
- workflow_dispatch:
-
-jobs:
- deploy:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: "3.8"
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install setuptools wheel twine
-
- - name: Build and publish to PyPI
- if: startsWith(github.ref, 'refs/tags')
- env:
- TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} #Same as Docker, need to add an account in the secrets
- TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
- run: |
- python setup.py sdist bdist_wheel
- twine upload dist/*
-
- - name: Build and publish to PyPI
- env:
- TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} #Same as Docker, need to add an account in the secrets
- TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
- run: |
- python setup.py sdist bdist_wheel
- twine upload --repository testpypi dist/*
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..eac3ad2e
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,72 @@
+name: Release with GitHub, PyPi, DockerHub
+
+on:
+ push:
+ branches: [master]
+ tags:
+ - "v*.*.*"
+ pull_request:
+ branches: [master]
+ tags:
+ - "v*.*.*"
+
+jobs:
+ github_release:
+ name: Release on GitHub
+ runs-on: ubuntu-latest
+ if: github.repository == 'crocs-muni/sec-certs'
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Release
+ uses: softprops/action-gh-release@v1
+ with:
+ prerelease: true
+ generate_release_notes: true
+
+ pypi_release:
+ name: Release on PyPi
+ runs-on: ubuntu-latest
+ if: github.repository == 'crocs-muni/sec-certs'
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.8"
+ - name: Install build dependencies
+ run: python -m pip install build wheel
+ - name: Build distributions
+ shell: bash -l {0}
+ run: python setup.py sdist bdist_wheel
+ - name: Publish package to PyPI
+ uses: pypa/gh-action-pypi-publish@master
+ with:
+ user: ${{ secrets.PYPI_USERNAME }}
+ password: ${{ secrets.PYPI_PASSWORD }}
+ docker:
+ name: Release on dockerhub
+ runs-on: ubuntu-latest
+ if: github.repository == 'crocs-muni/sec-certs'
+ steps:
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+ - name: Set up Docker Build
+ uses: docker/setup-buildx-action@v1
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
+ - name: Extract metadata (tags, labels) for Docker
+ id: meta
+ uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
+ with:
+ images: seccerts/sec-certs
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ file: docker/Dockerfile
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 63527213..656ce586 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -3,7 +3,7 @@ repos:
rev: 21.12b0
hooks:
- id: black
- language_version: python3.9
+ language_version: python3
args: ['--check']
- repo: https://github.com/pycqa/isort
rev: 5.10.1
diff --git a/docker/Dockerfile b/docker/Dockerfile
index df1345ca..a4eff99c 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,15 +1,7 @@
FROM ubuntu
-ARG NB_USER
-ARG NB_UID
-ENV USER ${NB_USER}
-ENV HOME /home/${NB_USER}
-
-RUN adduser --disabled-password \
- --gecos "Default user" \
- --uid ${NB_UID} \
- ${NB_USER}
-WORKDIR ${HOME}
+ENV USER="user"
+ENV HOME /home/${USER}
#installing dependencies
RUN apt-get update
@@ -17,31 +9,46 @@ RUN apt-get install python3 -y
RUN apt-get install python3-pip -y
RUN apt-get install python3-venv -y
RUN apt-get install git -y
-#------installing the needed thing for PyPDF2 and pdftotext-------------------------------------
+RUN apt-get install curl -y
+RUN apt-get install python3.8-venv -y
+
+# Install dependencies fo PyPDF2 and pdftotext
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
RUN apt-get install build-essential libpoppler-cpp-dev pkg-config python3-dev poppler-utils -y
RUN apt-get install libqpdf-dev -y
RUN apt-get install pkg-config -y
RUN apt-get install default-jdk -y
RUN apt-get install graphviz -y
-#-----------------------------------------------------------------------------------------------
+RUN adduser --disabled-password \
+ --gecos "Default user" \
+ ${USER}
+USER ${USER}
+WORKDIR ${HOME}
-RUN git clone https://github.com/crocs-muni/sec-certs.git /opt/sec-certs
+# TODO: Change dev to master
+# Download only snapshot of repository
+RUN \
+ curl -L https://api.github.com/repos/crocs-muni/sec-certs/tarball/master > sec-certs.tar.gz && \
+ mkdir sec-certs && \
+ tar zxf sec-certs.tar.gz --strip-components=1 --directory sec-certs && \
+ rm sec-certs.tar.gz
-#creating the venv in a way that works, the activation script doesn't work in Docker, we do manualy what it does
-ENV VIRTUAL_ENV=/opt/venv
-RUN python3 -m venv $VIRTUAL_ENV
-ENV PATH="$VIRTUAL_ENV/bin:$PATH"
+WORKDIR ${HOME}/sec-certs
-# Install dependencies:
-RUN cp /opt/sec-certs/requirements.txt .
-RUN pip install wheel
-RUN pip install -r requirements.txt
-RUN pip install --no-cache notebook
-#just to be sure that pdftotext is in $PATH
-ENV PATH /usr/bin/pdftotext:${PATH}
+# Create virtual environment
+ENV VENV_PATH=${HOME}/venv
+RUN python3 -m venv ${VENV_PATH}
+ENV PATH="${VENV_PATH}/bin:$PATH"
+# Install dependencies, notebook is because of mybinder.org
+RUN \
+ pip3 install wheel && \
+ pip3 install -r requirements.txt && \
+ pip3 install --no-cache notebook
+
+# #just to be sure that pdftotext is in $PATH
+ENV PATH /usr/bin/pdftotext:${PATH}
-# Run the application:
-CMD ["python3", "/opt/sec-certs/cc_cli.py"]
+# # Run the application:
+# CMD ["python3", "./cc_cli.py"]