Skip to content

Commit

Permalink
🐛 Issue with migrate script in docker (ajnart#1483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf authored Oct 22, 2023
1 parent 0a98be4 commit 6bcef9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ COPY ./src/migrate.ts ./src/migrate.ts
RUN apt-get update -y && apt-get install -y openssl

# Required for migration
RUN cp -r node_modules node_modules_cache
RUN rm -rf node_modules
RUN mv node_modules _node_modules
RUN rm package.json
RUN yarn add typescript ts-node dotenv [email protected] [email protected] @types/better-sqlite3
RUN mv node_modules node_modules_migrate
RUN mv _node_modules node_modules

# Expose the default application port
EXPOSE $PORT
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@
]
}
}
}
}
9 changes: 5 additions & 4 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

echo "Exporting hostname..."
export NEXTAUTH_URL_INTERNAL="http://$HOSTNAME:7575"

mv node_modules _node_modules
mv node_modules_migrate node_modules
echo "Migrating database..."
yarn ts-node src/migrate.ts & PID=$!
# Wait for migration to finish
wait $PID

echo "Reverting to production node_modules..."
# Copy specific sqlite3 binary to node_modules
cp /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/node_modules_cache/better-sqlite3/build/Release/better_sqlite3.node
cp /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/_node_modules/better-sqlite3/build/Release/better_sqlite3.node

# Remove node_modules and copy cached node_modules
rm -r /app/node_modules
cp -r /app/node_modules_cache /app/node_modules
mv node_modules node_modules_migrate
mv _node_modules node_modules
cp ./temp_package.json package.json
cp ./temp_yarn.lock yarn.lock

Expand Down

0 comments on commit 6bcef9e

Please sign in to comment.