Skip to the content.

๐ŸŒ Web Page | ๐Ÿ’ป Source Code | ๐Ÿš€ Releases

๐ŸŽ Packages | ๐Ÿณ Docker Hub

๐Ÿ“ logkey

A lightweight Python application to log user inputs into a CSV file with Docker support for easy deployment and GitHub Actions to automate key workflows.

logkey

๐Ÿ“š Table of Contents

(๐Ÿ” back to top)

๐Ÿ“Œ About

logkey is a Python-based application that logs user input into a CSV file. Users can configure the exit key and the CSV file name via command-line arguments. By default, the exit key is q, and the inputs are stored in inputs.csv.

(๐Ÿ” back to top)

๐Ÿš€ How to Run?

๐Ÿ Without Docker

๐Ÿ“‚ Clone the Repository

git clone https://github.com/imfsiddiqui/logkey
cd logkey

๐Ÿ“ฆ Install Dependencies

Ensure Python installed, then run:

pip install -r requirements.txt

โ–ถ๏ธ Run the Application

python app.py --exit-key <key> --csv-file <filename>

๐Ÿ’ก Example

python app.py --exit-key x --csv-file user_inputs.csv

This will log inputs to user_inputs.csv and exit when x is pressed.

๐Ÿณ With Docker

Ensure Docker installed, then follow the below instructions.

Note

In all the following commands:

๐Ÿ“ฅ Pull the Docker Image

Pull the prebuilt Docker image from Docker Hub:

docker pull imfsiddiqui/logkey

โ–ถ๏ธ Run the Application

Use the following command to run the application in a Docker container:

๐Ÿง Linux
docker run -it --rm -v $(pwd)/:/app/data/ imfsiddiqui/logkey \
  python app.py --exit-key <key> --csv-file /app/data/<filename>
๐ŸชŸ Windows: PowerShell
docker run -it --rm -v ${PWD}/:/app/data/ imfsiddiqui/logkey `
  python app.py --exit-key <key> --csv-file /app/data/<filename>

๐Ÿ’ก Example

๐Ÿง Linux
docker run -it --rm -v $(pwd)/:/app/data/ imfsiddiqui/logkey \
  python app.py --exit-key x --csv-file /app/data/user_inputs.csv
๐ŸชŸ Windows: PowerShell
docker run -it --rm -v ${PWD}/:/app/data/ imfsiddiqui/logkey `
  python app.py --exit-key x --csv-file /app/data/user_inputs.csv

This will log inputs to user_inputs.csv in the current directory on host machine and exit when x is pressed.

(๐Ÿ” back to top)

๐Ÿ› ๏ธ Development

If made any changes to the Python script app.py or update the requirements.txt file, follow these steps to rebuild and publish the Docker image.

๐Ÿ“‹ Update the requirements.txt File

New dependencies or libraries can be added to the project by adding their name in the requirements.txt file.

๐Ÿ—๏ธ Build the Docker Image

Rebuild the Docker image to include the latest changes:

๐Ÿง Linux

docker build -t logkey:latest -f ./Dockerfile .

๐ŸชŸ Windows: PowerShell

docker build -t logkey:latest -f .\Dockerfile .

๐Ÿงช Test the Docker Image Locally

Run the updated Docker image locally to ensure everything works as expected:

๐Ÿง Linux

docker run -it --rm -v $(pwd)/:/app/data/ logkey:latest \
  python app.py --exit-key x --csv-file /app/data/user_inputs.csv

๐ŸชŸ Windows: PowerShell

docker run -it --rm -v ${PWD}/:/app/data/ logkey:latest `
  python app.py --exit-key x --csv-file /app/data/user_inputs.csv

๐Ÿท๏ธ Tag the Docker Image

Tag the Docker image with a version number or latest:

docker tag logkey:latest imfsiddiqui/logkey:<version>

Replace <version> with the appropriate version number e.g. 1.0.1 or latest.

๐Ÿ“ค Push the Docker Image to Docker Hub

Publish the updated Docker image to Docker Hub:

docker push imfsiddiqui/logkey:<version>

latest tag can also be published:

docker push imfsiddiqui/logkey:latest

โœ… Verify the Published Image

Pull the image from Docker Hub to verify it was published correctly:

docker pull imfsiddiqui/logkey:<version>

or

docker pull imfsiddiqui/logkey:latest

Run the pulled image to ensure it works as expected:

๐Ÿง Linux

docker run -it --rm -v $(pwd)/:/app/data/ imfsiddiqui/logkey \
  python app.py --exit-key x --csv-file /app/data/user_inputs.csv

๐ŸชŸ Windows: PowerShell

docker run -it --rm -v ${PWD}/:/app/data/ imfsiddiqui/logkey `
  python app.py --exit-key x --csv-file /app/data/user_inputs.csv

By these steps, this can be ensured that updates are reflected in the Docker image and published for others to use.

(๐Ÿ” back to top)

๐Ÿ™ GitHub Actions

Following GitHub Actions are being used to automate key workflows:

๐Ÿค– .github/workflows/pages.yml

Automatically builds and deploys the documentation website using Jekyll whenever changes are pushed to the default branch main, a new tag starting with v (e.g., v1.0.0) is pushed, or the workflow is manually triggered.

๐Ÿค– .github/workflows/release.yml

Creates a new GitHub release when a tag starting with v is pushed. This automates the release process and makes new versions easily accessible to users.

๐Ÿค– .github/workflows/package.yml

Builds a Docker image and publishes it to GitHub Container Registry (ghcr.io) every time a new tag starting with v (e.g., v1.0.0) is pushed. This ensures the latest version of the application is always available as a container image.

(๐Ÿ” back to top)