🐛 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
# 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 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 $PORT

View File

@@ -250,4 +250,4 @@
]
}
}
}
}

View File

@@ -2,7 +2,8 @@
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
@@ -10,11 +11,11 @@ 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