This repository provides a solution for efficiently backing up LAMMPS projects hosted on GitHub. By leveraging Docker and Docker Compose, it establishes a reliable environment equipped with essential tools for comprehensive Git and GitHub operations, ensuring seamless and accessible backups of critical data.
The Dockerfile
is highly optimized for security, efficiency, and reproducibility. It leverages a multi-stage build to create a lean final image by excluding build-time dependencies.
Key features include:
- Essential Tools: Pre-installs
git
, GitHub CLI (gh
), and a Java Runtime Environment (default-jre
). - BFG Repo-Cleaner: Includes the
bfg.jar
and makes it executable via a simplebfg
command. - Security Hardening: The container runs as a non-root user (
appuser
) by default to enhance security. - Reproducibility: Base image and tool versions are pinned, ensuring consistent and reliable builds over time.
- Efficiency: Layer caching is optimized to ensure fast rebuilds when no source files have changed.
The docker-compose.yml
file simplifies container management. It is configured to:
- Build from Source: Automatically build the Docker image from the local
Dockerfile
. - Mount Volumes: Persist data by mounting the project directory into the container.
- Define the Service: Sets up the
lammps-github-backup-env
service for easy access.
To get started with this setup, follow these steps:
-
Clone the repository and navigate to the project's root directory.
-
Create a
.env
file by copying the existing.env-sample
file and modifying it as needed.
Once you've completed these steps, you can proceed with the following commands:
The recommended way to build and start the container is with Docker Compose. This command will build the image if it doesn't exist and start the service in the background.
docker compose up --detach --build
To stop and remove the container, use:
docker compose down
docker exec -it lammps-github-backup-env bash
You will be logged in as the non-root appuser
.
Note
Ensure your local repository is accessible in the WSL2 environment. Open the WSL2 terminal and navigate to your repository to run Docker commands seamlessly.
The provided Docker image is minimal to keep it small and secure. If you need additional tools like vim
or other utilities, you can extend the image:
- Modify the Dockerfile: Add a new
RUN
command to install the desired packages. For example, to addvim
:# ... inside the final stage, before the USER appuser line USER root RUN apk add --no-cache vim USER appuser
- Rebuild the image:
docker compose up --detach --build
Navigate to a local repository and run BFG to replace sensitive texts using the following command:
bfg --replace-text /home/passwords.txt --no-blob-protection
You can use the ./mkdir-for-lammps-results.sh
script to create a new folder with a formatted name, which helps in organizing your LAMMPS nanocutting-SiC results efficiently.
This script prompts you to input various parameters of your simulation, such as:
- Cutting Speed: Choose a value between 1 and 3.
- Groove Depth: Specify "no" for defect-free or select among 3, 6, or 9.
- Groove Shape: Select between isosceles acute (a) or isosceles right (r) if a groove depth is specified.
Based on these inputs, the script generates and creates a new folder with a name that accurately reflects the chosen simulation parameters.
To start using git in a folder, you need to initialize it as a repository. This will create a hidden .git
directory that contains the necessary files and metadata for git to track your changes.
To initialize git in a folder, open a terminal and navigate to the folder you want to use. Then, run the ../setup-git.sh
script. It will execute the git init
command and set up the git user name and email locally.
After you have git installed and configured in your folder. You can run the ../new-gitHub-repo.sh
script to set up the remote repository. The script will prompt you to choose a file type and then create a new private repository, with a name that reflects the file type and the simulation parameters, on GitHub using the GitHub CLI.
You can use the ./explore-github-repo.sh
script to carry out the following tasks:
- Open the GitHub repository in the browser
- Display the description and the README
- Check the disk usage
- Update the description
This script will first prompt you to enter the file type and the simulation parameters. It will resolve the repository name and then ask for the action you want to take.
You can use the ../git-readme-and-logfiles.sh
script to create commits for the README and log files in the folder that contains the simulation results.
This script will create the "Add README file" and "Add log files" commits.
You can use the ../commit-results-files.sh
script to create commits for the result files.
This script will prompt you to enter the cutting speed parameter. Then, it will use a loop to sequentially create commits for the indexed files in multiple batches. This way results in a set of commits that can be pushed to the remote repository in smaller chunks, reducing the risk of conflicts and errors.
You can use the ../progressive-push-latest-commits.sh
script in the folder that contains the simulation results.
Enter the number of revisions before the HEAD. For example, input 10
to the prompt will start from HEAD~10
and push commits to remote one by one with a 5-minute break in between.
You can use the ./ovito.sh
script to quick open the OVITO program on Windows, and preload the state files specifying in the script file.
If you prefer to use PowerShell on Windows, run the ./ovito.ps1
script file instead.