mirror of
https://github.com/evroon/bracket.git
synced 2026-05-04 05:58:23 -04:00
Fix docker entrypoint (#886)
This commit is contained in:
@@ -18,6 +18,9 @@ RUN set -ex \
|
||||
|
||||
EXPOSE 8400
|
||||
|
||||
HEALTHCHECK --interval=15s --timeout=5s --retries=5 \
|
||||
CMD wget --spider http://localhost:8400 || exit 1
|
||||
|
||||
CMD pipenv run gunicorn \
|
||||
-k uvicorn.workers.UvicornWorker \
|
||||
bracket.app:app \
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
version: '3.1'
|
||||
|
||||
networks:
|
||||
bracket_lan:
|
||||
driver: bridge
|
||||
@@ -14,6 +12,7 @@ services:
|
||||
- postgres
|
||||
environment:
|
||||
ENVIRONMENT: DEVELOPMENT
|
||||
CORS_ORIGINS: http://localhost:3000
|
||||
PG_DSN: postgresql://bracket_dev:bracket_dev@postgres:5432/bracket_dev
|
||||
image: ghcr.io/evroon/bracket-backend
|
||||
networks:
|
||||
|
||||
@@ -15,7 +15,9 @@ WORKDIR /app
|
||||
COPY . .
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
|
||||
RUN NEXT_PUBLIC_API_BASE_URL="APP_PLACEHOLDER_NEXT_PUBLIC_API_BASE_URL" NEXT_PUBLIC_HCAPTCHA_SITE_KEY="APP_PLACEHOLDER_NEXT_PUBLIC_HCAPTCHA_SITE_KEY" yarn build
|
||||
RUN NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER \
|
||||
NEXT_PUBLIC_HCAPTCHA_SITE_KEY=NEXT_PUBLIC_HCAPTCHA_SITE_KEY_PLACEHOLDER \
|
||||
yarn build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM node:18-alpine AS runner
|
||||
@@ -47,4 +49,7 @@ EXPOSE 3000
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
HEALTHCHECK --interval=15s --timeout=5s --retries=5 \
|
||||
CMD wget --spider http://localhost:3000 || exit 1
|
||||
|
||||
CMD yarn start
|
||||
|
||||
33
frontend/docker-entrypoint.sh
Normal file → Executable file
33
frontend/docker-entrypoint.sh
Normal file → Executable file
@@ -1,28 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
# Script to replace `NEXT_PUBLIC_*` environment variables because they're set
|
||||
# at build-time but we want to set them at runtime in `docker-compose.yml`
|
||||
if [ -z ${NEXT_PUBLIC_API_BASE_URL+x} ];
|
||||
then echo "Environment variable `NEXT_PUBLIC_API_BASE_URL` is not set, please set it in docker-compose.yml";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# The first part wrapped in a function
|
||||
makeSedCommands() {
|
||||
printenv | \
|
||||
grep '^NEXT_PUBLIC' | \
|
||||
sed -r "s/=/ /g" | \
|
||||
xargs -n 2 bash -c 'echo "sed -i \"s#APP_PLACEHOLDER_$0#$1#g\""'
|
||||
|
||||
# Replace the statically built placeholder literals from Dockerfile with run-time
|
||||
# the value of the `NEXT_PUBLIC_WEBAPP_URL` environment variable
|
||||
replace_placeholder() {
|
||||
find .next public -type f |
|
||||
while read file; do
|
||||
sed -i "s|$1|$2|g" "$file" || true
|
||||
done
|
||||
}
|
||||
|
||||
# Set the delimiter to newlines (needed for looping over the function output)
|
||||
IFS=$'\n'
|
||||
# For each sed command
|
||||
for c in $(makeSedCommands); do
|
||||
# For each file in the .next directory
|
||||
for f in $(find .next -type f); do
|
||||
# Execute the command against the file
|
||||
COMMAND="$c $f"
|
||||
eval $COMMAND
|
||||
done
|
||||
done
|
||||
replace_placeholder "http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER" "$NEXT_PUBLIC_API_BASE_URL"
|
||||
replace_placeholder "NEXT_PUBLIC_HCAPTCHA_SITE_KEY_PLACEHOLDER" "$NEXT_PUBLIC_HCAPTCHA_SITE_KEY"
|
||||
|
||||
echo "Starting Nextjs"
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user