forked from blockscout/frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image build process improvements (blockscout#1045)
* auto-generate .env.production file * env placeholders congruity check * refactor yarn dev and docker tasks * [skip ci] pass git tag and commit sha to dev app * [skip ci] clean up
- Loading branch information
Showing
23 changed files
with
282 additions
and
171 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
node_modules_linux | ||
|
||
playwright/envs.js | ||
playwright/envs.js | ||
deploy/tools/envs-validator/index.js |
This file contains 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 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 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 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 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 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 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,45 @@ | ||
#!/bin/bash | ||
|
||
# Check if the number of arguments provided is correct | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <input_file>" | ||
exit 1 | ||
fi | ||
|
||
input_file="$1" | ||
prefix="NEXT_PUBLIC_" | ||
|
||
# Function to make the environment variables template file | ||
# It will read the input file, extract all prefixed string and use them as variables names | ||
# This variables will have placeholders for their values at buildtime which will be replaced with actual values at runtime | ||
make_envs_template_file() { | ||
output_file=".env.production" | ||
|
||
# Check if file already exists and empty its content if it does | ||
if [ -f "$output_file" ]; then | ||
> "$output_file" | ||
fi | ||
|
||
grep -oE "${prefix}[[:alnum:]_]+" "$input_file" | sort -u | while IFS= read -r var_name; do | ||
echo "$var_name=__PLACEHOLDER_FOR_${var_name}__" >> "$output_file" | ||
done | ||
} | ||
|
||
# Function to save build-time environment variables to .env file | ||
save_build-time_envs() { | ||
output_file=".env" | ||
|
||
# Check if file already exists and empty its content if it does or create a new one | ||
if [ -f "$output_file" ]; then | ||
> "$output_file" | ||
else | ||
touch "$output_file" | ||
fi | ||
|
||
env | grep "^${prefix}" | while IFS= read -r line; do | ||
echo "$line" >> "$output_file" | ||
done | ||
} | ||
|
||
make_envs_template_file | ||
save_build-time_envs |
This file contains 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 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,6 @@ | ||
/node_modules | ||
.env | ||
.env.production | ||
index.js | ||
envs.ts | ||
schema.ts |
This file contains 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,8 @@ | ||
#!/bin/bash | ||
|
||
cp ../../../types/envs.ts . | ||
export NEXT_PUBLIC_GIT_COMMIT_SHA=$(git rev-parse --short HEAD) | ||
export NEXT_PUBLIC_GIT_TAG=$(git describe --tags --abbrev=0) | ||
../../scripts/make_envs_template.sh ../../../docs/ENVS.md | ||
yarn build | ||
dotenv -e ../../../configs/envs/.env.main -e ../../../configs/envs/.env.secrets yarn validate |
Oops, something went wrong.