Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dockerfile to build docker images from the source #75

Merged
merged 7 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/release_containers.yml
Original file line number Diff line number Diff line change
@@ -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 }}
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>" \
org.opencontainers.image.title="enex2notion" \
org.opencontainers.image.description="Import Evernote ENEX files to Notion " \
org.opencontainers.image.authors="vzhd1701 <[email protected]>" \
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"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down