Skip to content

polyu-kyfung/lammps-github-backup-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub-CLI Docker for LAMMPS Project Backup

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.

Dockerfile Overview

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 simple bfg 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.

Docker Compose Overview

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.

How to Use

To get started with this setup, follow these steps:

  1. Clone the repository and navigate to the project's root directory.

  2. 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:

Build and Start the Container

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

Execute an Interactive Bash Shell on the Container

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.

Extending the Docker Image

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:

  1. Modify the Dockerfile: Add a new RUN command to install the desired packages. For example, to add vim:
    # ... inside the final stage, before the USER appuser line
    USER root
    RUN apk add --no-cache vim
    USER appuser
  2. Rebuild the image:
    docker compose up --detach --build

Remove Sensitive Data from the Git History

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

Utils (Shell Scripts)

Interactively Create a New Folder for LAMMPS Nanocutting-SiC Results

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.

Initialize git in a folder

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.

Create a new remote repository on GitHub

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.

Quick menu to explore and edit a GitHub repository

You can use the ./explore-github-repo.sh script to carry out the following tasks:

  1. Open the GitHub repository in the browser
  2. Display the description and the README
  3. Check the disk usage
  4. 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.

Commit readme and log files

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.

Commit dump/force/rerun files

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.

Push commits to remote one by one

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.

Open the OVITO GUI program

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.

About

Dockerized solution for seamless backup of LAMMPS projects on GitHub

Topics

Resources

License

Stars

Watchers

Forks