Skip to content

Replace script #3281

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ services:
dockerfile: ./docker/api.Containerfile
# https://docs.docker.com/reference/compose-file/build/#target
target: production

Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove trailing spaces.

Static analysis reported trailing spaces on this line. Please remove any extraneous whitespace to adhere to YAML formatting standards.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 22-22: trailing spaces

(trailing-spaces)

entrypoint: ["/bin/sh", "-c", "replaceJwt.sh"]
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Review the new entrypoint directive.

The addition of the entrypoint directive:

entrypoint: ["/bin/sh", "-c", "replaceJwt.sh"]

ensures that the replaceJwt.sh script runs when the api service starts. Please verify the following:

  • The replaceJwt.sh script exists in the repository root, is executable (with the correct shebang), and has proper error handling.
  • The script correctly replaces the REPLACE_WITH_RANDOM_JWT_TOKEN placeholder in your environment files.
  • The script eventually hands over control to the main application process (e.g., via an exec command) so that the container’s PID 1 is properly managed.

If you need assistance in enhancing or verifying the script’s behavior, please let me know.

# https://docs.docker.com/reference/compose-file/services/#depends_on
depends_on:
minio:
Expand Down
2 changes: 1 addition & 1 deletion envFiles/.env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ API_IS_APPLY_DRIZZLE_MIGRATIONS=true
API_IS_GRAPHIQL=false
API_IS_PINO_PRETTY=false
API_JWT_EXPIRES_IN=2592000000
API_JWT_SECRET=b4896453be722d5ca94058a73f52b31c75980b485fa6d74d91f417a8059d8731
API_JWT_SECRET=REPLACE_WITH_RANDOM_JWT_TOKEN
API_LOG_LEVEL=info
API_MINIO_ACCESS_KEY=talawa
API_MINIO_END_POINT=minio
Expand Down
2 changes: 1 addition & 1 deletion envFiles/.env.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ API_IS_APPLY_DRIZZLE_MIGRATIONS=true
API_IS_GRAPHIQL=false
API_IS_PINO_PRETTY=false
API_JWT_EXPIRES_IN=2592000000
API_JWT_SECRET=dd06f326a810d9c7dd67b1428a4caef558d9e730d25e5440945f82948a56d96cd6f972222768cd2d77c28ad833f4a4a475a9828f87ac0ac3ec94df276fe24736
API_JWT_SECRET=REPLACE_WITH_RANDOM_JWT_TOKEN
API_LOG_LEVEL=info
API_MINIO_ACCESS_KEY=talawa
API_MINIO_END_POINT=minio
Expand Down
2 changes: 1 addition & 1 deletion envFiles/.env.devcontainer
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ API_IS_APPLY_DRIZZLE_MIGRATIONS=true
API_IS_GRAPHIQL=true
API_IS_PINO_PRETTY=true
API_JWT_EXPIRES_IN=2592000000
API_JWT_SECRET=b4896453be722d5ca94058a73f52b31c75980b485fa6d74d91f417a8059d8731
API_JWT_SECRET=REPLACE_WITH_RANDOM_JWT_TOKEN
API_LOG_LEVEL=debug
API_MINIO_ACCESS_KEY=talawa
API_MINIO_END_POINT=minio
Expand Down
2 changes: 1 addition & 1 deletion envFiles/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ API_IS_APPLY_DRIZZLE_MIGRATIONS=true
API_IS_GRAPHIQL=false
API_IS_PINO_PRETTY=false
API_JWT_EXPIRES_IN=2592000000
API_JWT_SECRET=
API_JWT_SECRET=REPLACE_WITH_RANDOM_JWT_TOKEN
API_LOG_LEVEL=info
API_MINIO_ACCESS_KEY=talawa
API_MINIO_END_POINT=minio
Expand Down
12 changes: 12 additions & 0 deletions replaceJwt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Define the path to the compose file
COMPOSE_FILE="./.env"

# Generate a random JWT-like token (modify this logic if needed)
RANDOM_TOKEN=$(openssl rand -base64 32 | tr -d '=+/')

# Replace placeholder with the generated token
sed -i "s/REPLACE_WITH_RANDOM_JWT_TOKEN/$RANDOM_TOKEN/g" "$COMPOSE_FILE"

echo "Token replaced successfully!"
Loading