diff --git a/.github/workflows/release_containers.yml b/.github/workflows/release_containers.yml new file mode 100644 index 0000000..cbf73af --- /dev/null +++ b/.github/workflows/release_containers.yml @@ -0,0 +1,78 @@ +name: release_containers + +on: + workflow_dispatch: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + release_ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + if: github.event_name == 'workflow_dispatch' + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + echo "TAG_VERSION=$LATEST_TAG" >> $GITHUB_ENV + + - name: Get push tag version + if: github.event_name == 'push' + run: echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Publish Docker image to GitHub Container Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: ${{ github.repository }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + tags: "latest,${{ env.TAG_VERSION }}" + platforms: linux/amd64,linux/arm64 + + release_docker: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout latest release tag + if: github.event_name == 'workflow_dispatch' + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout $LATEST_TAG + echo "TAG_VERSION=$LATEST_TAG" >> $GITHUB_ENV + + - name: Get push tag version + if: github.event_name == 'push' + run: echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Publish Docker image to Docker Container Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: ${{ github.repository }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + tags: "latest,${{ env.TAG_VERSION }}" + platforms: linux/amd64,linux/arm64 + + - name: Update Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + repository: ${{ github.repository }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bfed6b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM debian:12-slim AS build + +ENV BUILD_POETRY_VERSION=1.6.1 + +RUN apt-get update && \ + apt-get install --no-install-suggests --no-install-recommends --yes python3-venv python3-pip && \ + python3 -m venv /venv && \ + /venv/bin/pip install --upgrade pip + +RUN pip3 install --break-system-packages poetry==$BUILD_POETRY_VERSION + +FROM build AS build-venv + +COPY . /app +WORKDIR /app + +RUN poetry build --no-interaction -f wheel +RUN /venv/bin/pip install --disable-pip-version-check dist/*.whl + +FROM gcr.io/distroless/python3-debian12 + +ENV INSIDE_DOCKER_CONTAINER=1 + +LABEL maintainer="vzhd1701 " \ + org.opencontainers.image.title="enex2notion" \ + org.opencontainers.image.description="Import Evernote ENEX files to Notion " \ + org.opencontainers.image.authors="vzhd1701 " \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.documentation="https://github.com/vzhd1701/enex2notion" \ + org.opencontainers.image.url="https://github.com/vzhd1701/enex2notion" \ + org.opencontainers.image.source="https://github.com/vzhd1701/enex2notion.git" + +COPY --from=build-venv /venv /venv + +WORKDIR /input + +ENTRYPOINT ["/venv/bin/enex2notion"] diff --git a/README.md b/README.md index 19aafe5..014c094 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,14 @@ $ brew install enex2notion $ pipx install enex2notion ``` +### With [**Docker**](https://docs.docker.com/) + +This command maps current directory `$PWD` to the `/input` directory in the container. You can replace `$PWD` with a directory that contains your `*.enex` files. When running commands like `enex2notion /input` refer to your local mapped directory as `/input`. + +```shell +$ docker run --rm -t -v "$PWD":/input vzhd1701/enex2notion:latest +``` + ### With PIP ```bash