🐛 Issue with migrate script in docker (#1483)

This commit is contained in:
Meier Lukas
2023-10-22 17:59:21 +02:00
committed by GitHub
parent 0a98be4553
commit 6bcef9e24c
3 changed files with 9 additions and 7 deletions

View File

@@ -25,10 +25,11 @@ COPY ./src/migrate.ts ./src/migrate.ts
RUN apt-get update -y && apt-get install -y openssl RUN apt-get update -y && apt-get install -y openssl
# Required for migration # Required for migration
RUN cp -r node_modules node_modules_cache RUN mv node_modules _node_modules
RUN rm -rf node_modules
RUN rm package.json RUN rm package.json
RUN yarn add typescript ts-node dotenv drizzle-orm@0.28.6 better-sqlite3@8.6.0 @types/better-sqlite3 RUN yarn add typescript ts-node dotenv drizzle-orm@0.28.6 better-sqlite3@8.6.0 @types/better-sqlite3
RUN mv node_modules node_modules_migrate
RUN mv _node_modules node_modules
# Expose the default application port # Expose the default application port
EXPOSE $PORT EXPOSE $PORT

View File

@@ -2,7 +2,8 @@
echo "Exporting hostname..." echo "Exporting hostname..."
export NEXTAUTH_URL_INTERNAL="http://$HOSTNAME:7575" export NEXTAUTH_URL_INTERNAL="http://$HOSTNAME:7575"
mv node_modules _node_modules
mv node_modules_migrate node_modules
echo "Migrating database..." echo "Migrating database..."
yarn ts-node src/migrate.ts & PID=$! yarn ts-node src/migrate.ts & PID=$!
# Wait for migration to finish # Wait for migration to finish
@@ -10,11 +11,11 @@ wait $PID
echo "Reverting to production node_modules..." echo "Reverting to production node_modules..."
# Copy specific sqlite3 binary to 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 # Remove node_modules and copy cached node_modules
rm -r /app/node_modules mv node_modules node_modules_migrate
cp -r /app/node_modules_cache /app/node_modules mv _node_modules node_modules
cp ./temp_package.json package.json cp ./temp_package.json package.json
cp ./temp_yarn.lock yarn.lock cp ./temp_yarn.lock yarn.lock