Skip to content
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

Export all *_FILE variables (Improve docker secret files usage) #234

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
21471a9
Stop the container if it can't get wiki settings
pastakhov Dec 5, 2024
6a893fc
change messages
pastakhov Dec 5, 2024
90c32e1
printf "\nCheck wiki settings for errors... "
pastakhov Dec 5, 2024
29be8ad
BOOTSTRAP_LOGFILE="$MW_LOG/_bootstrap_$(date -u +%Y%m%d).log"
pastakhov Dec 5, 2024
dee9a39
+echo "See Bash XTrace in the $BOOTSTRAP_LOGFILE file" + stdbuf
pastakhov Dec 5, 2024
8e3d4a4
Fix exec 3>>"$BOOTSTRAP_LOGFILE"
pastakhov Dec 5, 2024
645ad53
export BOOTSTRAP_LOGFILE="$MW_LOG/_bootstrap_$(date -u +%Y%m%d).log"
pastakhov Dec 5, 2024
c453306
fix dublicate messages in subscripts
pastakhov Dec 5, 2024
cc151a7
BOOTSTRAP_LOGFILE="$MW_LOG/_bootstrap_$(date -u +%Y%m%d_%H%M%S).log"
pastakhov Dec 5, 2024
1a2e8c3
Restore printf "\n\n===== update-images-permissions.sh =====\n\n\n"
pastakhov Dec 5, 2024
1be2921
exec > >(stdbuf -o0 tee -a "$BOOTSTRAP_LOGFILE") 2>&1
pastakhov Dec 5, 2024
85b4463
exec 3> >(stdbuf -oL tee -a "$BOOTSTRAP_LOGFILE" >/dev/null)
pastakhov Dec 5, 2024
3d6ac64
Export all *_FILE variables (Improve docker secret files usage)
pastakhov Dec 18, 2024
c2545eb
write variables to /etc/environment and read them in /etc/profile
pastakhov Dec 19, 2024
d64cd23
fix Modify /etc/profile
pastakhov Dec 19, 2024
9c781a4
fix2 "Modify /etc/profile"
pastakhov Dec 19, 2024
ad1d0ee
Modify /etc/bash.bashrc
pastakhov Dec 19, 2024
7e59ebe
Merge branch 'master' into WIK-1735/improve_secret_files_usage
pastakhov Dec 20, 2024
0e49088
improve log messages
pastakhov Dec 20, 2024
08ce953
update README.md
pastakhov Dec 20, 2024
c98d058
add SHELL ["/bin/bash", "-l", "-c"]
pastakhov Dec 20, 2024
7e1438b
remove SHELL ["/bin/bash", "-l", "-c"]
pastakhov Dec 22, 2024
fe3682a
Add _sources/scripts/profile.d/load-env-vars.sh
pastakhov Dec 22, 2024
499fe12
Restore "Modify /etc/bash.bashrc"
pastakhov Dec 22, 2024
6672e0f
update load-env-vars.sh
pastakhov Dec 22, 2024
e6ca380
declare -x "$line"
pastakhov Dec 22, 2024
10dc079
add a comment
pastakhov Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
declare -x "$line"
  • Loading branch information
pastakhov committed Dec 22, 2024
commit e6ca3806db962de918babb3418ce971776fa0aa1
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
APACHE_LOG_DIR=/var/log/apache2

# System setup
RUN set x; \

Check failure on line 19 in Dockerfile

View workflow job for this annotation

GitHub Actions / test

DL3047 info: Avoid use of wget without progress bar. Use `wget --progress=dot:giga <url>`.Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`).
apt-get clean \
&& apt-get update \
&& apt-get --no-install-recommends install -y aptitude \
Expand Down Expand Up @@ -1015,7 +1015,7 @@
COPY --from=composer $MW_ORIGIN_FILES $MW_ORIGIN_FILES

# Default values
ENV MW_AUTOUPDATE=true \

Check warning on line 1018 in Dockerfile

View workflow job for this annotation

GitHub Actions / push

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "MW_PASSWORD_SENDER") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
MW_MAINTENANCE_UPDATE=0 \
MW_ENABLE_EMAIL=0 \
MW_ENABLE_USER_EMAIL=0 \
Expand Down Expand Up @@ -1100,10 +1100,8 @@
&& mkdir -p $MW_ORIGIN_FILES/extensions/Widgets \
&& mv $MW_HOME/extensions/Widgets/compiled_templates $MW_ORIGIN_FILES/extensions/Widgets/ \
&& ln -s $MW_VOLUME/extensions/Widgets/compiled_templates $MW_HOME/extensions/Widgets/compiled_templates \
# Modify /etc/bash.bashrc
&& echo 'if [ -f /etc/environment ]; then' >> /etc/bash.bashrc \
&& echo ' export $(grep -v "^#" /etc/environment | xargs)' >> /etc/bash.bashrc \
&& echo 'fi' >> /etc/bash.bashrc
# Modify /etc/bash.bashrc (loaded for `docker-compose exec web bash` command)
&& echo '. /etc/profile.d/load-env-vars.sh' >> /etc/bash.bashrc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would adding this to ~/.bashrc here instead of /etc/bash.bashrc fix the issue Alexey pointed out on the task?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't. The difference only that /etc/bash.bashrc is global and runs ~/.bashrc for the current user. I guess we need it for all the users (to be run globally)


COPY _sources/images/Powered-by-Canasta.png /var/www/mediawiki/w/resources/assets/

Expand Down
9 changes: 8 additions & 1 deletion _sources/scripts/profile.d/load-env-vars.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# loaded for the `docker-compose exec web bash -cl '...'` command

if [ -f /etc/environment_secrets ]; then
# Get the system start time and environment secrets modification time
Expand All @@ -8,6 +9,12 @@ if [ -f /etc/environment_secrets ]; then
# Compare timestamps
if [ "$ENV_SECRETS_MOD_TIME" -ge "$CONTAINER_START_TIME" ]; then
# The file was created after the system started, we can use it
export "$(grep -v "^#" /etc/environment_secrets | xargs)"
# Read and export each line (ignoring comments) individually
while IFS= read -r line; do
# Skip empty lines and lines starting with '#'
if [[ -n "$line" && "$line" != \#* ]]; then
declare -x "$line"
fi
done < /etc/environment_secrets
fi
fi
Loading