From f74288239d81d3409fca3588dd25fd8ad61506d7 Mon Sep 17 00:00:00 2001 From: Sitnikov Timofey Date: Wed, 26 Nov 2025 09:24:21 +0300 Subject: [PATCH 1/5] A Dockerfile has been added for application containerization. The application can now be run in an isolated Docker container. --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile 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" ] From 7b0cd4c706d941555c8a4182d4775e3059fad422 Mon Sep 17 00:00:00 2001 From: Sitnikov Timofey Date: Wed, 26 Nov 2025 09:27:39 +0300 Subject: [PATCH 2/5] Instructions for running with Docker have been added to `README.md`. A "Running with Docker" subsection has been added to the Usage section with command examples: - Building a Docker image - Basic container launch - Launching with additional parameters Now users can easily run an application in a Docker container without having to install dependencies on the system. --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e566c98..7ea7603 100644 --- a/README.md +++ b/README.md @@ -57,11 +57,22 @@ python3 main.py --words 100 python3 main.py --forever ``` +### Running with Docker +```bash +# Build the Docker image +docker build -t typr . + +# Run the container +docker run -it --rm typr + +# Run with custom options +docker run -it --rm typr python3 main.py --time 60 --forgive-errors +``` + ## 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 +80,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/) From 43b15bd497ae65e411204b78eab10aa0ec985ce6 Mon Sep 17 00:00:00 2001 From: Sitnikov Timofey Date: Wed, 26 Nov 2025 09:33:11 +0300 Subject: [PATCH 3/5] Added a GitHub Actions workflow for automatically building and publishing Docker images. A `.github/workflows/docker.yml` file has been created that: - Automatically runs on pushes to main, v* tags, and pull requests - Builds a Docker image using Buildx - Automatically logs into the GitHub Container Registry - Generates tags for images based on: - Branch (for main) - PR number - Tag semver (v1.0.0 -> 1.0.0, 1.0) - Commit SHA - Uses caching to speed up builds - Publishes the image only on pushes (not on pull requests) Images are now automatically built and published to GHCR with every code change. --- .github/workflows/docker.yml | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..f18a54b --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,55 @@ +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 + + - 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 From c27a063ee3571556ceb2f15041d0a3fe175b3a8b Mon Sep 17 00:00:00 2001 From: Sitnikov Timofey Date: Wed, 26 Nov 2025 09:42:25 +0300 Subject: [PATCH 4/5] feat: add latest tag to Docker image builds - Added 'latest' tag generation for pushes to main branch - Updated docker/metadata-action configuration with raw type tag - Tag 'latest' will now be published alongside other tags when pushing to main This ensures that the most recent stable build is always accessible with the 'latest' tag, improving developer experience and deployment workflows. --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f18a54b..88d4dce 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -43,6 +43,7 @@ jobs: 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 From 92051227c3980cf9eaa8f30b39dd7f8a18f5f697 Mon Sep 17 00:00:00 2001 From: Sitnikov Timofey Date: Wed, 26 Nov 2025 09:45:33 +0300 Subject: [PATCH 5/5] Updated `README.md` with instructions for running a pre-built Docker image. In the "Running with Docker" section, a section has been added for using a pre-built image: - The pre-built image `ghcr.io/imperatormarsa/typr` is specified. - Added example commands for running the latest version. - Separated instructions into the recommended method (pre-built image) and building from source. Now users can run the application directly without having to build an image. --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7ea7603..6a351df 100644 --- a/README.md +++ b/README.md @@ -58,15 +58,22 @@ 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 - -# Run with custom options -docker run -it --rm typr python3 main.py --time 60 --forgive-errors ``` ## Roadmap