Skip to content
Closed
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
5 changes: 4 additions & 1 deletion scripts/runserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ until pg_isready -h ${DB_CONTAINER_NAME} -p 5432; do
done

should_install_first_problem=false
if [[ -f docker-dev || -f docker-release ]] && [ -d static-tmp ]; then
PROBLEM_COUNT=$(PGPASSWORD="$(sed -n 's/^DB_PASSWORD=//p' scripts/.docker-init.env)" psql -h "${DB_CONTAINER_NAME}" -U ntoj -d ntoj -tAc "SELECT count(*) FROM problem" 2>/dev/null || echo "0")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.docker-init.env is deleted by docker-init, thereby causing the not found error once I don't restart the container:

sed: can't read scripts/.docker-init.env: No such file or directory

rm scripts/.docker-init.env

PROB_COUNT=$(echo "$PROB_COUNT" | xargs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PROBLEM_COUNT


if [[ -f docker-dev || -f docker-release ]] && [ -d static-tmp ] && [ "$PROBLEM_COUNT" -eq 0 ]; then
should_install_first_problem=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PROBLEM_COUNT check should be separated from docker-init:

if [[ -f docker-dev || -f docker-release ]] && [ -d static-tmp ]; then
    if [ "$PROBLEM_COUNT" -eq 0 ]; then
        should_install_first_problem=true
    fi
    
    ./scripts/docker-init.sh
fi

Otherwise, it causes the following error:

cp: cannot stat 'config.py': No such file or directory

./scripts/docker-init.sh
fi
Expand Down
Loading