๐ 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.
๐ 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
.
๐ง Philosophyโ
The philosophy behind logkey is to demonstrate the use of Python with Docker and how GitHub Actions can be used to automate key workflows like GitHub Pages deployment, release management, and Docker image packaging.
๐ Key Featuresโ
- Docker Support: Run the application in a Docker container for easy deployment and portability.
- GitHub Actions: Automate workflows for documentation deployment, release management, and Docker image packaging.
- Open Source: Licensed under the MIT License, allowing anyone to use, modify, and distribute it freely.
๐ How to Run?โ
๐ Without Dockerโ
๐ Clone the Repositoryโ
git clone https://github.com/imfsiddiqui/logkey
cd logkey
imfsiddiqui
is the GitHub username.logkey
is the repository name.
๐ฆ Install Dependenciesโ
Ensure Python installed, then run:
pip install -r requirements.txt
โถ๏ธ Run the Applicationโ
python src/logkey/logkey.py --exit-key <key> --csv-file <filename>
- Replace
<key>
with your desired exit key (default isq
). - Replace
<filename>
with your desired CSV file name (default isinputs.csv
).
๐ก Exampleโ
python src/logkey/logkey.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.
In all the following commands:
imfsiddiqui
is the Docker Hub username.logkey
is the Docker image name.
๐ฅ 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 src/logkey/logkey.py --exit-key <key> --csv-file /app/data/<filename>
๐ช Windows: PowerShellโ
docker run -it --rm -v ${PWD}/:/app/data/ imfsiddiqui/logkey `
python src/logkey/logkey.py --exit-key <key> --csv-file /app/data/<filename>
- The
-v $(pwd)/:/app/data/
or-v ${PWD}/:/app/data/
option mounts the current working directory from host machine to the/app/data/
directory inside the container. This ensures that any CSV files created or updated by the application are stored persistently on host machine, even after the container stops. - Replace
<key>
with your desired exit key (default isq
). - Replace
<filename>
with your desired CSV file name (default isinputs.csv
).
๐ก Exampleโ
๐ง Linuxโ
docker run -it --rm -v $(pwd)/:/app/data/ imfsiddiqui/logkey \
python src/logkey/logkey.py --exit-key x --csv-file /app/data/user_inputs.csv
๐ช Windows: PowerShellโ
docker run -it --rm -v ${PWD}/:/app/data/ imfsiddiqui/logkey `
python src/logkey/logkey.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.
๐ ๏ธ Developmentโ
If made any changes to the Python script src/logkey/logkey.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 src/logkey/logkey.py --exit-key x --csv-file /app/data/user_inputs.csv
๐ช Windows: PowerShellโ
docker run -it --rm -v ${PWD}/:/app/data/ logkey:latest `
python src/logkey/logkey.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 src/logkey/logkey.py --exit-key x --csv-file /app/data/user_inputs.csv
๐ช Windows: PowerShellโ
docker run -it --rm -v ${PWD}/:/app/data/ imfsiddiqui/logkey `
python src/logkey/logkey.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.
๐ GitHub Actionsโ
Following GitHub Actions are being used to automate key workflows:
๐ค .github/workflows/pages.yamlโ
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.yamlโ
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.yamlโ
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.
๐ Important Documentsโ
- Changelog: Changelog of all notable changes.
- Code of Conduct: Code of Conduct for contributors.
- Commit Message Instructions: Commit message guidelines for contributors and Copilot.
- Contribution Guidelines: How to contribute to this project.
- License: License text.
- Pull Request Description Instructions: Pull request guidelines for contributors and Copilot.
- Roadmap: High-level strategic plan, long-term goals, milestones, and overall project vision.
- Security Policy: Security policy and reporting instructions.
- Todo: Day-to-day task tracking and immediate execution.
๐ Licenseโ
This project is licensed under the MIT License, allowing anyone to use, modify, and distribute it freely for personal or commercial purposes.