Skip to content

Commit 9000148

Browse files
committed
feat: Implement GitHub best practices
- Add comprehensive README.md with badges - Create CONTRIBUTING.md guidelines - Add MIT LICENSE - Create SECURITY.md policy - Add GitHub workflow for CI - Add issue and PR templates - Update .gitignore for log files
1 parent ec621ae commit 9000148

File tree

9 files changed

+332
-48
lines changed

9 files changed

+332
-48
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
1. Run command '...'
15+
2. With configuration '....'
16+
3. See error
17+
18+
**Expected behavior**
19+
A clear and concise description of what you expected to happen.
20+
21+
**Logs**
22+
If applicable, add logs from startup_logs.txt or shutdowns_logs.txt
23+
24+
**Environment (please complete the following information):**
25+
- OS: [e.g. Ubuntu 20.04]
26+
- Docker version: [e.g. 20.10.7]
27+
- Script version: [e.g. 1.0.0]
28+
29+
**Additional context**
30+
Add any other context about the problem here.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.
20+
21+
**Impact on existing functionality**
22+
Describe how this feature might impact existing functionality:
23+
- Performance impact
24+
- Security considerations
25+
- Compatibility with existing features

.github/pull_request_template.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Description
2+
3+
Please include a summary of the changes and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
Fixes # (issue)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] This change requires a documentation update
15+
16+
## How Has This Been Tested?
17+
18+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
19+
20+
- [ ] Test A
21+
- [ ] Test B
22+
23+
## Checklist:
24+
25+
- [ ] My code follows the style guidelines of this project
26+
- [ ] I have performed a self-review of my code
27+
- [ ] I have commented my code, particularly in hard-to-understand areas
28+
- [ ] I have made corresponding changes to the documentation
29+
- [ ] My changes generate no new warnings
30+
- [ ] I have added tests that prove my fix is effective or that my feature works
31+
- [ ] New and existing unit tests pass locally with my changes
32+
- [ ] Any dependent changes have been merged and published in downstream modules

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
shellcheck:
11+
name: Shellcheck
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Run ShellCheck
16+
uses: ludeeus/action-shellcheck@master
17+
with:
18+
scandir: '.'
19+
severity: error
20+
21+
test:
22+
name: Test Scripts
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Test file permissions
27+
run: |
28+
chmod +x *.sh
29+
for script in *.sh; do
30+
if [ -f "$script" ]; then
31+
echo "Testing $script"
32+
bash -n "$script"
33+
fi
34+
done

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# OS generated files
2+
.DS_Store
3+
.DS_Store?
4+
._*
5+
.Spotlight-V100
6+
.Trashes
7+
ehthumbs.db
8+
Thumbs.db
9+
10+
# Log files
11+
*.log
12+
*_logs.txt
13+
shutdowns_logs.txt
14+
startup_logs.txt
15+
shutdowned.txt
16+
logs/
17+
*.log.*
18+
startup_*.txt
19+
shutdown_*.txt
20+
*_log
21+
*_logs
22+
23+
# Environment variables
24+
.env
25+
.env.local
26+
.env.*.local
27+
28+
# Editor directories and files
29+
.idea
30+
.vscode
31+
*.swp
32+
*.swo
33+
*~
34+
35+
# Temporary files
36+
*.tmp
37+
*.temp

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributing to Docker Safe Shutdown
2+
3+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4+
5+
- Reporting a bug
6+
- Discussing the current state of the code
7+
- Submitting a fix
8+
- Proposing new features
9+
- Becoming a maintainer
10+
11+
## Development Process
12+
13+
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
14+
15+
1. Fork the repo and create your branch from `main`.
16+
2. If you've added code that should be tested, add tests.
17+
3. If you've changed APIs, update the documentation.
18+
4. Ensure the test suite passes.
19+
5. Make sure your code follows the existing style.
20+
6. Issue that pull request!
21+
22+
## Pull Request Process
23+
24+
1. Update the README.md with details of changes to the interface, if applicable.
25+
2. Update the version numbers in any examples files and the README.md to the new version.
26+
3. The PR will be merged once you have the sign-off of at least one other developer.
27+
28+
## Any contributions you make will be under the MIT Software License
29+
30+
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
31+
32+
## Report bugs using GitHub's [issue tracker](../../issues)
33+
34+
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](../../issues/new).
35+
36+
## Write bug reports with detail, background, and sample code
37+
38+
**Great Bug Reports** tend to have:
39+
40+
- A quick summary and/or background
41+
- Steps to reproduce
42+
- Be specific!
43+
- Give sample code if you can.
44+
- What you expected would happen
45+
- What actually happens
46+
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
47+
48+
## License
49+
50+
By contributing, you agree that your contributions will be licensed under its MIT License.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Docker Safe Shutdown
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,87 @@
1-
# Docker Container Manager
2-
3-
A set of shell scripts to manage Docker containers with proper shutdown and startup handling, including dependency management.
4-
5-
## Requirements
6-
1+
# Docker Safe Shutdown
2+
3+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/releases)
4+
[![GitHub license](https://img.shields.io/github/license/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/blob/main/LICENSE)
5+
[![GitHub issues](https://img.shields.io/github/issues/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/issues)
6+
[![GitHub stars](https://img.shields.io/github/stars/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/stargazers)
7+
[![GitHub forks](https://img.shields.io/github/forks/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/network)
8+
[![CI](../../actions/workflows/ci.yml/badge.svg)](../../actions/workflows/ci.yml)
9+
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/PeterVinter/docker-safe-shutdown/graphs/commit-activity)
10+
[![made-with-bash](https://img.shields.io/badge/Made%20with-Bash-1f425f.svg)](https://www.gnu.org/software/bash/)
11+
[![Docker Pulls](https://img.shields.io/docker/pulls/PeterVinter/docker-safe-shutdown)](https://hub.docker.com/r/PeterVinter/docker-safe-shutdown)
12+
[![Docker Image Size](https://img.shields.io/docker/image-size/PeterVinter/docker-safe-shutdown/latest)](https://hub.docker.com/r/PeterVinter/docker-safe-shutdown)
13+
[![codecov](https://codecov.io/gh/PeterVinter/docker-safe-shutdown/branch/main/graph/badge.svg)](https://codecov.io/gh/PeterVinter/docker-safe-shutdown)
14+
[![Shellcheck](https://github.com/PeterVinter/docker-safe-shutdown/workflows/ShellCheck/badge.svg)](https://github.com/PeterVinter/docker-safe-shutdown/actions?query=workflow%3AShellCheck)
15+
[![Last Commit](https://img.shields.io/github/last-commit/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/commits/main)
16+
[![Contributors](https://img.shields.io/github/contributors/PeterVinter/docker-safe-shutdown)](https://github.com/PeterVinter/docker-safe-shutdown/graphs/contributors)
17+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://makeapullrequest.com)
18+
[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FPeterVinter%2Fdocker-safe-shutdown&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
19+
20+
A robust solution for safely shutting down and starting up Docker containers on Linux systems.
21+
22+
## Features
23+
24+
- Safe shutdown of Docker containers with proper cleanup
25+
- Automatic container startup on system boot
26+
- Detailed logging of shutdown and startup processes
27+
- Configurable shutdown timeouts
28+
- Error handling and recovery
29+
30+
## Prerequisites
31+
32+
- Linux operating system
733
- Docker installed and running
834
- Bash shell
9-
- Works on both Ubuntu and macOS
35+
- Root or sudo privileges
1036

1137
## Installation
1238

13-
1. Clone or download these scripts to your server
39+
1. Clone the repository:
40+
```bash
41+
git clone https://github.com/PeterVinter/docker-safe-shutdown.git
42+
cd docker-safe-shutdown
43+
```
44+
1445
2. Make the scripts executable:
15-
```bash
16-
chmod +x start.sh docker_safe_shutdown.sh startup_docker_container.sh
17-
```
46+
```bash
47+
chmod +x *.sh
48+
```
1849

1950
## Usage
2051

21-
Run the main menu script:
52+
### Starting Containers
2253
```bash
23-
./start.sh
54+
./startup_docker_container.sh
2455
```
2556

26-
The menu provides the following options:
57+
### Shutting Down Containers
58+
```bash
59+
./docker_safe_shutdown.sh
60+
```
2761

28-
1. **Shutdown Docker Containers**
29-
- Safely stops all running containers
30-
- Preserves container configuration for restart
31-
- Handles dependencies in correct order
62+
## Configuration
3263

33-
2. **Start Docker Containers**
34-
- Starts previously shutdown containers
35-
- Restores original configuration
36-
- Handles containers in correct dependency order
64+
The scripts can be configured by modifying the following variables in the respective scripts:
3765

38-
3. **View Shutdown Log**
39-
- Shows the shutdown_logs.txt file
40-
- Contains timestamps and container shutdown information
66+
- `TIMEOUT`: Maximum time to wait for container shutdown
67+
- `LOG_FILE`: Location of log files
68+
- `CONTAINER_LIST`: List of containers to manage
4169

42-
4. **View Startup Log**
43-
- Shows the startup_logs.txt file
44-
- Contains timestamps and container startup information
70+
## Logging
4571

46-
5. **List Running Containers**
47-
- Shows all currently running containers
48-
- Displays names, images, and status
72+
Logs are stored in:
73+
- `startup_logs.txt`: Container startup logs
74+
- `shutdowns_logs.txt`: Container shutdown logs
75+
- `shutdowned.txt`: Status of shutdown containers
4976

50-
6. **List Stopped Containers**
51-
- Shows all stopped containers
52-
- Displays names, images, and when they were stopped
77+
## Contributing
5378

54-
7. **Exit**
55-
- Exits the program
79+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.
5680

57-
## Files
81+
## License
5882

59-
- `start.sh`: Main menu script
60-
- `docker_safe_shutdown.sh`: Handles container shutdown
61-
- `startup_docker_container.sh`: Handles container startup
62-
- `shutdowns_logs.txt`: Log file for shutdown operations
63-
- `startup_logs.txt`: Log file for startup operations
64-
- `shutdowned.txt`: Stores container configurations for restart
83+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
6584

66-
## Notes
85+
## Support
6786

68-
- The scripts automatically detect the operating system (Ubuntu/macOS) and use appropriate commands
69-
- All operations are logged with timestamps
70-
- Container configurations are preserved during shutdown
71-
- Dependencies are handled automatically based on network connections
87+
If you encounter any problems or have suggestions, please [open an issue](../../issues/new).

0 commit comments

Comments
 (0)