Skip to content

Commit 4d72f82

Browse files
committed
feat: run prisma migration in our production DB instance every deploy
1 parent 1e6af09 commit 4d72f82

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@ RUN pnpm build
1010
FROM node:22-slim
1111
WORKDIR /app
1212
ENV PORT=3000
13-
ENV HOST=0.0.0.0
13+
# TODO: see if AWS needs the HOST env
14+
# ENV HOST=0.0.0.0
15+
ENV HOSTNAME=0.0.0.0
1416
EXPOSE 3000
1517

18+
RUN apt-get update -y && apt-get install -y --no-install-recommends openssl ca-certificates \
19+
&& rm -rf /var/lib/apt/lists/*;
20+
21+
RUN npm install -g prisma@^6.15.0
22+
1623
COPY --from=builder /app/.next/standalone ./
1724
COPY --from=builder /app/.next/static ./.next/static
1825
# TODO: uncomment once we add images to /public
1926
# COPY --from=builder /app/public ./public
2027

28+
COPY --from=builder /app/prisma ./prisma
29+
30+
COPY docker-entrypoint.sh /entrypoint.sh
31+
RUN chmod +x /entrypoint.sh
32+
ENTRYPOINT ["/entrypoint.sh"]
33+
2134
CMD ["node", "server.js"]

docker-entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
# docker-entrypoint.sh
3+
# This script is ran on every deploy within our production docker container
4+
set -eu
5+
echo "Running Prisma migrations..."
6+
prisma migrate deploy
7+
echo "Starting app..."
8+
exec "$@"

start.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
2-
2+
# start.sh
3+
# This script is for developers to use during local development
34
cleanup() {
45
docker compose down
56
exit 0

0 commit comments

Comments
 (0)