Created
April 23, 2024 17:20
-
-
Save wnqueiroz/eb7beaf2bc92e126f8921bb0feb9f50c to your computer and use it in GitHub Desktop.
Next.js 12-factor App Support
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
# -------------------------- .docker/entrypoint.sh -------------------------- | |
#!/bin/bash | |
DIR=".next" | |
find "${DIR}" -type f | while read -r file; do | |
for var in $(env | cut -d= -f1 | grep '^NEXT_PUBLIC'); do | |
PATTERN="\$${var}" | |
NEW_VALUE=$(eval echo "\$$var") | |
SED_COMMAND="s|${PATTERN}|${NEW_VALUE}|g" | |
sed -i "${SED_COMMAND}" "${file}" | |
done | |
done | |
HOSTNAME="0.0.0.0" yarn start | |
# -------------------------- Dockerfile -------------------------- | |
CMD sh .docker/entrypoint.sh | |
# -------------------------- NEXT_PUBLIC_* envs usage -------------------------- | |
const MY_API_KEY = process.env.NEXT_PUBLIC_MY_API_KEY || "$NEXT_PUBLIC_MY_API_KEY"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment