diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..88d4dce --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,56 @@ +name: Build and Publish Docker image + +on: + push: + branches: [main] + tags: ["v*"] + pull_request: + branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d9ee8a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.14-slim + +WORKDIR /app +COPY ./main.py main.py +COPY ./settings.json settings.json +COPY ./word_frequency.json word_frequency.json +COPY ./words.txt words.txt +COPY ./words_i_like.txt words_i_like.txt + +CMD [ "python", "main.py" ] diff --git a/README.md b/README.md index e566c98..6a351df 100644 --- a/README.md +++ b/README.md @@ -57,11 +57,29 @@ python3 main.py --words 100 python3 main.py --forever ``` +### Running with Docker +#### Using pre-built image (recommended) +```bash +# Run the latest version +docker run -it --rm ghcr.io/imperatormarsa/typr + +# Run with custom options +docker run -it --rm ghcr.io/imperatormarsa/typr python3 main.py --time 60 --forgive-errors +``` + +#### Building from source +```bash +# Build the Docker image +docker build -t typr . + +# Run the container +docker run -it --rm typr +``` + ## Roadmap - [ ] Add a setting for the wordlist. - [ ] Add a setting for the language. - ## Contributing Pull requests are welcome. For major changes, please open an issue first @@ -69,4 +87,4 @@ to discuss what you would like to change. ## License -[GPL-3.0](https://choosealicense.com/licenses/gpl-3.0/) \ No newline at end of file +[GPL-3.0](https://choosealicense.com/licenses/gpl-3.0/)