-
Notifications
You must be signed in to change notification settings - Fork 375
explore: non-root user for docker #1589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eric-intuitem
wants to merge
69
commits into
main
Choose a base branch
from
fix/docker-app-user
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
1c922bf
Update Dockerfile
eric-intuitem 75bffc8
Delete readme.txt
eric-intuitem 812de5e
restrict user for frontend
eric-intuitem c31aafb
Update Dockerfile
eric-intuitem e1299a5
Create readme.txt
eric-intuitem 313e420
Update Dockerfile
eric-intuitem 1c3e023
Update startup-tests.yml
eric-intuitem 868380e
Update startup-tests.yml
eric-intuitem 23033a4
another test
eric-intuitem 3afce1d
Update startup-tests.yml
eric-intuitem de85136
Update Dockerfile
eric-intuitem 282b343
Update Dockerfile
eric-intuitem 7b6c64b
Update startup.sh
eric-intuitem 8730446
Update startup.sh
eric-intuitem 63493b1
Update startup-tests.yml
eric-intuitem 7bd6bad
Update startup.sh
eric-intuitem f10016e
WIP
eric-intuitem 5be9ca7
Update Dockerfile
eric-intuitem a9a824e
Update startup.sh
eric-intuitem 1e0dd04
Update startup-tests.yml
eric-intuitem fda2d80
Update startup-tests.yml
eric-intuitem 0cbd9b0
Update startup-tests.yml
eric-intuitem 8448ac9
Update docker-compose-build.yml
eric-intuitem 310df30
WIP
eric-intuitem fea748d
Update docker-compose-build.yml
eric-intuitem a010250
Update docker-compose-build.yml
eric-intuitem 1c56c24
Update startup-tests.yml
eric-intuitem ddd432a
Update startup-tests.yml
eric-intuitem da79fb6
Update startup-tests.yml
eric-intuitem 80bc579
WIP
eric-intuitem 8399c9b
WIP
eric-intuitem 0122617
Update startup-tests.yml
eric-intuitem 7238cd7
Update Dockerfile
eric-intuitem f73b87e
Update startup-tests.yml
eric-intuitem 3cf8ef0
WIP
eric-intuitem 0b2bdb5
Update startup-tests.yml
eric-intuitem 2cf5602
Update startup-tests.yml
eric-intuitem e2f0af6
Update Dockerfile
eric-intuitem 233503d
WIP
eric-intuitem f7eab93
Update Dockerfile
eric-intuitem eebfb33
Update docker-compose-build.yml
eric-intuitem edbded1
WIP
eric-intuitem fe24b8a
Update Dockerfile
eric-intuitem 4eb4255
Update startup-tests.yml
eric-intuitem ae131bb
Update startup-tests.yml
eric-intuitem aa2c37d
Update startup-tests.yml
eric-intuitem c9b7d56
Update docker-compose-build.yml
eric-intuitem de2ddb7
Update Dockerfile
eric-intuitem 95cc9a8
use docker named volume instead of mount-dir
eric-intuitem b9dc1e9
WIP
eric-intuitem 5afd278
Update startup-tests.yml
eric-intuitem 10df56d
Update docker-compose-build.yml
eric-intuitem 0776d4a
use volume for EE
eric-intuitem e64123e
fix EE test
eric-intuitem feb3bf0
use volume for docker-compose.sh
eric-intuitem 8df65e3
use volume for docker-compose.sh
eric-intuitem 944634d
Update docker-compose-build.yml
eric-intuitem 9dfae46
add sudo and update doc
eric-intuitem 62bb591
WIP
eric-intuitem 22be866
WIP
eric-intuitem ebbb275
Update docker-compose-build.yml
eric-intuitem df74261
WIP
eric-intuitem 443c449
Merge branch 'main' into fix/docker-app-user
eric-intuitem c5ca2a0
WIP
eric-intuitem 6ac2f2c
fix codefactor-detected error
eric-intuitem f9f2b2c
fix EE
eric-intuitem 4e03efd
Update README.md
eric-intuitem b339fb2
Add script to simplify migration
eric-intuitem b81524c
adapt to Debian-based frontend
eric-intuitem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,8 +133,6 @@ jobs: | |
run: pnpm exec playwright install | ||
- name: Build the Docker app | ||
run: | | ||
rm -rf db | ||
mkdir db | ||
docker compose -f docker-compose-build.yml up -d | ||
- name: Create backend environment variables file | ||
working-directory: ${{ env.backend-directory }} | ||
|
@@ -143,7 +141,10 @@ jobs: | |
export $(grep -v '^#' .env | xargs) | ||
- name: Config the Docker app | ||
run: | | ||
sleep 120 # give the migrations time to finish (included in the up on the previous step) | ||
until docker compose -f docker-compose-build.yml exec -T backend curl -f http://localhost:8000/api/build >/dev/null 2>&1; do | ||
echo "Backend is not ready - waiting 10s..." | ||
sleep 10 | ||
done | ||
docker compose -f docker-compose-build.yml exec backend /bin/bash -c "[email protected] DJANGO_SUPERUSER_PASSWORD=1234 poetry run python manage.py createsuperuser --noinput && exit 0" | ||
- name: Run tests | ||
working-directory: ${{ env.frontend-directory }} | ||
|
@@ -270,15 +271,19 @@ jobs: | |
working-directory: ${{ env.enterprise-frontend-build-directory }} | ||
run: pnpm exec playwright install | ||
- name: Build the Docker app | ||
run: docker compose -f enterprise/docker-compose-build.yml up -d | ||
run: | | ||
docker compose -f enterprise/docker-compose-build.yml up -d | ||
- name: Create backend environment variables file | ||
working-directory: ${{ env.backend-directory }} | ||
run: | | ||
touch .env | ||
export $(grep -v '^#' .env | xargs) | ||
- name: Config the Docker app | ||
run: | | ||
sleep 120 # give the migrations time to finish (included in the up on the previous step) | ||
until docker compose -f enterprise/docker-compose-build.yml exec -T backend curl -f http://localhost:8000/api/build >/dev/null 2>&1; do | ||
echo "Backend is not ready - waiting 10s..." | ||
sleep 10 | ||
done | ||
docker compose -f enterprise/docker-compose-build.yml exec backend /bin/bash -c "[email protected] DJANGO_SUPERUSER_PASSWORD=1234 poetry run python manage.py createsuperuser --noinput --settings=${{ env.enterprise-backend-settings-module }} && exit 0" | ||
- name: Run tests | ||
working-directory: ${{ env.frontend-directory }} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Simple script to migrate a local dir ("db") to Docker named volumes: | ||
# - <prefix>db for the backend and huey | ||
# - <prefix>caddy_data for Caddy (ONLY IF "caddy" exists) | ||
# Default prefix: "ciso-assistant-community_" | ||
# Usage: docker-migrate-dir-to-volume.sh <path_to_db_dir> [optional_prefix] | ||
|
||
# Check if at least one argument (directory path) is provided | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <path_to_db_dir> [optional_prefix]" | ||
exit 1 | ||
fi | ||
|
||
# Resolve full path to avoid issues with relative paths | ||
DB_DIR="$(realpath "$1")" | ||
|
||
# Check if the directory exists | ||
if [ ! -d "$DB_DIR" ]; then | ||
echo "❌ Error: Directory '$DB_DIR' does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Set volume prefix (default: "ciso-assistant-community_") | ||
VOLUME_PREFIX="${2:-ciso-assistant-community_}" | ||
|
||
# Define main volume | ||
DB_VOLUME="${VOLUME_PREFIX}db" | ||
|
||
echo "📦 Creating Docker volume for the database..." | ||
docker volume create "$DB_VOLUME" | ||
|
||
echo "📂 Copying contents of '$DB_DIR' to '$DB_VOLUME' volume..." | ||
docker run --rm -v "$DB_VOLUME":/mnt/volume -v "$DB_DIR":/mnt/source ubuntu bash -c "cp -r /mnt/source/. /mnt/volume/ && chown -R 1001:1001 /mnt/volume" | ||
|
||
# Check if the "caddy" directory exists before creating the volume | ||
if [ -d "$DB_DIR/caddy" ]; then | ||
CADDY_VOLUME="${VOLUME_PREFIX}caddy_data" | ||
|
||
echo "📦 Creating Docker volume for Caddy..." | ||
docker volume create "$CADDY_VOLUME" | ||
|
||
echo "📂 Copying 'caddy' contents to '$CADDY_VOLUME' volume..." | ||
docker run --rm -v "$CADDY_VOLUME":/mnt/volume -v "$DB_DIR/caddy":/mnt/source ubuntu bash -c "cp -r /mnt/source/. /mnt/volume/" | ||
|
||
echo "✅ '$CADDY_VOLUME' copied successfully." | ||
else | ||
echo "⚠️ 'caddy' directory not found. Skipping volume creation." | ||
fi | ||
|
||
echo "✅ Migration complete! Volumes are ready to use." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding strict mode for improved error handling.
Immediately after the shebang, add
set -euo pipefail
to ensure the script fails on errors and handles unset variables safely.