diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..6ec6595 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,19 @@ +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + publish_docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: hunyadi/md2conf + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + dockerfile: Dockerfile_dist + tags: "latest,${{ github.ref_name }}" \ No newline at end of file diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml new file mode 100644 index 0000000..0165d1d --- /dev/null +++ b/.github/workflows/publish-python.yml @@ -0,0 +1,27 @@ +name: Publish Python Package + +on: + release: + types: [published] + +jobs: + pypi-publish: + name: Publish release to PyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install build + - name: Build package + run: | + python -m build --wheel --sdist + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_ID_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 07be08a..08f46a4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ /*.egg-info .envrc .venv +.idea diff --git a/Dockerfile b/Dockerfile index 895b23f..d3425d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG PYTHON_VERSION=3.11 +ARG PYTHON_VERSION=3.9 FROM python:${PYTHON_VERSION}-alpine RUN python3 -m pip install --upgrade pip COPY dist/*.whl dist/ diff --git a/Dockerfile_dist b/Dockerfile_dist new file mode 100644 index 0000000..39e2c08 --- /dev/null +++ b/Dockerfile_dist @@ -0,0 +1,19 @@ +ARG PYTHON_VERSION=3.9 + +FROM python:${PYTHON_VERSION}-alpine as builder + +COPY ./ ./ + +RUN python3 -m pip install --upgrade pip && \ + pip install build && \ + python -m build --wheel + +FROM python:${PYTHON_VERSION}-alpine as runner + +COPY --from=builder /dist/*.whl dist/ + +RUN python3 -m pip install `ls -1 dist/*.whl` && \ + apk add --update nodejs npm && \ + npm install -g @mermaid-js/mermaid-cli + +ENTRYPOINT ["python3", "-m", "md2conf"] diff --git a/README.md b/README.md index 4affc77..a828ad0 100644 --- a/README.md +++ b/README.md @@ -149,3 +149,30 @@ optional arguments: --ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations. --local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API. ``` + +### Using the docker container + +You can run the docker container via docker run or via dockerfile. Either can accept the environment variables or argument similar to the python options. +The final argument `./` is mdpath. + +* `docker run --rm --name md2conf hunyadi/md2conf -d instructure.atlassian.net -u levente.hunyadi@instructure.com -a 0123456789abcdef -s DAP ./` + +Note that the entrypont for the docker container's base image is `ENTRYPOINT ["python3", "-m", "md2conf"]` +```Dockerfile +FROM hunyadi/md2conf:latest + +ENV CONFLUENCE_DOMAIN='instructure.atlassian.net' +ENV CONFLUENCE_PATH='/wiki/' +ENV CONFLUENCE_USER_NAME='levente.hunyadi@instructure.com' +ENV CONFLUENCE_API_KEY='0123456789abcdef' +ENV CONFLUENCE_SPACE_KEY='DAP' + +CMD ["./"] +``` +or via arguments + + ```Dockerfile +FROM hunyadi/md2conf:latest + +CMD ["-d", "instructure.atlassian.net", "-u", "levente.hunyadi@instructure.com", "-a", "0123456789abcdef", "-s", "DAP", "./"] +```