Simple HTML / CSS / JS image gallery made for my cat and deployed with Docker.
View Demo
·
Report Bug or
·
Request Feature
Table of Contents
Warning
This project is now migrated to https://github.com/AitorAstorga/image_gallery as part of my new efforts to erase JavaScript from the Earth. Glory to WebAssembly compiled by the grace of the all-powerful Rust!
This project is an image gallery application that dynamically generates a JSON list of images from a specified directory. It uses Nginx to serve the content and monitors the images directory for any changes, updating the JSON file accordingly. The application is containerized using Docker and integrated with GitHub Actions for continuous integration and deployment.
This project is built with the following technologies:
To get a local copy up and running follow these simple example steps.
- Docker installed on your local machine
- Git installed on your local machine
- A GitHub account with repository access
- Clone the repository to your local machine using the following command:
git clone https://github.com/AitorAstorga/Image-Gallery.git - Navigate to the project directory:
cd Image-Gallery - Ensure that Docker is installed and running on your machine.
To use this project with your own GitHub repository, you need to clone the repo, change the docker-image.yml, and configure your GitHub fork with a secret token:
- Fork the repository on GitHub.
- Clone your forked repository to your local machine:
git clone https://github.com/yourusername/your-forked-repo.git - Navigate to the project directory:
cd your-forked-repo - Make any required changes to the project.
- In your GitHub repository, go to Settings > Secrets and Variables > Actions.
- Add a new secret named
GHCR_TOKENusing a token generated from GitHub Tokens.
Note
Replace my name in docker-image.yml like so:
# Build the Docker image
- name: Build the Docker image
run: docker build . --file Dockerfile --tag aichan-image-gallery:latest --tag ghcr.io/your_username/aichan-image-gallery:latest
# Push the Docker image to GHCR
- name: Push Docker images to GHCR
run: |
# Push the main app image
docker push ghcr.io/your_username/aichan-image-gallery:latest
Example to serve the application using Docker:
- Build the Docker image with the following command:
docker build -t aichan-image-gallery:latest . - Run the Docker container:
docker run -d -p 80:80 aichan-image-gallery:latest - Access the application by navigating to
http://localhostin your web browser.
The project uses GitHub Actions to automate the building and pushing of Docker images. The workflow is defined in the .github/workflows/docker-image.yml file. On every push or pull request to the main branch, the workflow performs the following steps:
- Checks out the repository code.
- Logs in to the GitHub Container Registry using a secret token.
- Builds the Docker image with the tags
aichan-image-gallery:latestandghcr.io/aitorastorga/aichan-image-gallery:latest. - Pushes the Docker images to the GitHub Container Registry.
The Dockerfile sets up an Nginx server to serve the image gallery. It performs the following actions:
- Uses the latest Nginx image as the base.
- Installs
inotify-toolsto monitor directory changes. - Removes the existing HTML directory in Nginx.
- Copies the project repository into the Nginx HTML directory.
- Adds the
generate_images_json.shscript to the container and makes it executable. - Creates a custom entrypoint script that runs the JSON generation script in the background and starts Nginx.
- Exposes port 80 for the Nginx server.
This Bash script generates a JSON file listing all image files in the images directory. It performs the following functions:
- Scans the
imagesdirectory for files with extensions.jpg,.jpeg,.png, and.gif. - Creates or updates the
images.jsonfile with the list of image filenames. - Uses
inotifywaitto monitor theimagesdirectory for any creation, deletion, or movement of image files and regenerates the JSON file upon detecting such events.
The GitHub Actions workflow defined in .github/workflows/docker-image.yml automates the continuous integration process by:
- Triggering on pushes and pull requests to the main branch.
- Checking out the repository code.
- Logging into the GitHub Container Registry using a secure token.
- Building the Docker image with appropriate tags.
- Pushing the Docker image to the GitHub Container Registry for deployment.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the European Union Public License v1.2. See LICENSE for more information.
Aitor Astorga Saez de Vicuña - [email protected]
Project Link: https://github.com/AitorAstorga/Image-Gallery
Thanks to these nice projects!