-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
test deploy using docker-compose with env variable inject during dock…
…er compose up
1 parent
90cda20
commit b9061ee
Showing
8 changed files
with
171 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
NEXT_PUBLIC_AZURE_CLIENT_ID=NEXT_PUBLIC_AZURE_CLIENT_ID | ||
NEXT_PUBLIC_AZURE_REDIRECT_URI=NEXT_PUBLIC_AZURE_REDIRECT_URI | ||
NEXT_PUBLIC_SITE_URL=NEXT_PUBLIC_SITE_URL | ||
NEXT_PUBLIC_BACKEND_URL=NEXT_PUBLIC_BACKEND_URL | ||
NEXT_PUBLIC_MICROSERVICE_URL=NEXT_PUBLIC_MICROSERVICE_URL | ||
NEXT_PUBLIC_LOGIN_REQUEST_SCOPE=NEXT_PUBLIC_LOGIN_REQUEST_SCOPE |
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,11 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Docker Compose Dev" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker"> | ||
<deployment type="docker-compose.yml"> | ||
<settings> | ||
<option name="envFilePath" value="" /> | ||
<option name="sourceFilePath" value="docker-compose-dev.yml" /> | ||
</settings> | ||
</deployment> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Docker Image Pull" type="docker-deploy" factoryName="docker-image" server-name="Docker"> | ||
<deployment type="docker-image"> | ||
<settings> | ||
<option name="imageTag" value="xeroxisxs/eduquest-frontend-nextjs:latest" /> | ||
<option name="containerName" value="" /> | ||
<option name="commandLineOptions" value="--platform linux/amd64" /> | ||
</settings> | ||
</deployment> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,34 @@ | ||
#services: | ||
# eduquest-frontend: | ||
# build: | ||
# context: . | ||
# dockerfile: Dockerfile | ||
# entrypoint: ["/entrypoint.sh"] | ||
# ports: | ||
# - "3000:80" | ||
# restart: always | ||
# volumes: | ||
# - /app/node_modules | ||
# - /app/.next | ||
# environment: | ||
# NEXT_PUBLIC_SITE_URL: ${NEXT_PUBLIC_SITE_URL} | ||
# NEXT_PUBLIC_AZURE_CLIENT_ID: ${NEXT_PUBLIC_AZURE_CLIENT_ID} | ||
# NEXT_PUBLIC_AZURE_REDIRECT_URI: ${NEXT_PUBLIC_AZURE_REDIRECT_URI} | ||
# NEXT_PUBLIC_BACKEND_URL: ${NEXT_PUBLIC_BACKEND_URL} | ||
# NEXT_PUBLIC_MICROSERVICE_URL: ${NEXT_PUBLIC_MICROSERVICE_URL} | ||
# NEXT_PUBLIC_LOGIN_REQUEST_SCOPE: ${NEXT_PUBLIC_LOGIN_REQUEST_SCOPE} | ||
# | ||
services: | ||
frontend: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- "3000:80" | ||
environment: | ||
NEXT_PUBLIC_SITE_URL: ${NEXT_PUBLIC_SITE_URL} | ||
NEXT_PUBLIC_AZURE_CLIENT_ID: ${NEXT_PUBLIC_AZURE_CLIENT_ID} | ||
NEXT_PUBLIC_AZURE_REDIRECT_URI: ${NEXT_PUBLIC_AZURE_REDIRECT_URI} | ||
NEXT_PUBLIC_BACKEND_URL: ${NEXT_PUBLIC_BACKEND_URL} | ||
NEXT_PUBLIC_MICROSERVICE_URL: ${NEXT_PUBLIC_MICROSERVICE_URL} | ||
NEXT_PUBLIC_LOGIN_REQUEST_SCOPE: ${NEXT_PUBLIC_LOGIN_REQUEST_SCOPE} |
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 |
---|---|---|
@@ -1,22 +1,26 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
envFilename='./.env.production' | ||
nextFolder='./standalone/.next/' | ||
|
||
echo "Starting entrypoint script..." | ||
while read -r line; do | ||
# no comment or not empty | ||
if [ "${line:0:1}" == "#" ] || [ "${line}" == "" ]; then | ||
continue | ||
fi | ||
|
||
# Check environment variables | ||
echo "Checking environment variables..." | ||
[ -z "$NEXT_PUBLIC_AZURE_CLIENT_ID" ] && echo "NEXT_PUBLIC_AZURE_CLIENT_ID is not set" && exit 1 | ||
[ -z "$NEXT_PUBLIC_AZURE_REDIRECT_URI" ] && echo "NEXT_PUBLIC_AZURE_REDIRECT_URI is not set" && exit 1 | ||
[ -z "$NEXT_PUBLIC_SITE_URL" ] && echo "NEXT_PUBLIC_SITE_URL is not set" && exit 1 | ||
[ -z "$NEXT_PUBLIC_BACKEND_URL" ] && echo "NEXT_PUBLIC_BACKEND_URL is not set" && exit 1 | ||
[ -z "$NEXT_PUBLIC_MICROSERVICE_URL" ] && echo "NEXT_PUBLIC_MICROSERVICE_URL is not set" && exit 1 | ||
[ -z "$NEXT_PUBLIC_LOGIN_REQUEST_SCOPE" ] && echo "NEXT_PUBLIC_LOGIN_REQUEST_SCOPE is not set" && exit 1 | ||
# split | ||
configName="$(cut -d'=' -f1 <<<"$line")" | ||
configValue="$(cut -d'=' -f2 <<<"$line")" | ||
# get system env | ||
envValue=$(env | grep "^$configName=" | grep -oe '[^=]*$') | ||
|
||
echo "All required environment variables are set." | ||
# if config found && configName starts with NEXT_PUBLIC | ||
if [ -n "$configValue" ] && [ -n "$envValue" ]; then | ||
# replace all | ||
echo "Replace: ${configValue} with ${envValue}" | ||
find $nextFolder \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#$configValue#$envValue#g" | ||
fi | ||
done <$envFilename | ||
|
||
# Replace placeholders in .next files | ||
echo "Replacing placeholders in .next files..." | ||
# Add your placeholder replacement logic here | ||
|
||
# Execute the main command | ||
echo "Executing command: npm start" | ||
exec npm start | ||
echo "Starting Nextjs" | ||
exec "$@" |
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