0xsh
0xsh
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
hopefully i find a better solution
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
thank you mate, i tried to do it with the depends but made it a lot complex so i left it to do full copy node modules for now
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
FROM node:latest AS base

FROM base AS deps
WORKDIR /app

COPY package.json package-lock.json .npmrc ./

RUN npm ci

FROM base AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN npm run build

FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

RUN mkdir .next
RUN chown nextjs:nodejs .next

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

COPY --from=builder --chown=nextjs:nodejs /app/db ./db
COPY --from=builder --chown=nextjs:nodejs /app/drizzle.config.ts ./drizzle.config.ts

COPY --from=deps /app/node_modules ./node_modules # any possible way to remove this?

ENV HOME=/home/nextjs
RUN mkdir -p /home/nextjs/.local/share && chown -R nextjs:nodejs /home/nextjs # this is for drizzle-kit, it needs this dir for drizzle studio. definitely a bug from drizzle-kit

RUN echo '#!/bin/sh' > /app/start.sh && \
echo 'set -e' >> /app/start.sh && \
echo 'npm run migrate' >> /app/start.sh && \ # it runs "drizzle-kit migrate" be better if i could just run migrate.ts/.mjs with node
echo 'exec node server.js' >> /app/start.sh && \
chmod +x /app/start.sh

USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["/app/start.sh"]
FROM node:latest AS base

FROM base AS deps
WORKDIR /app

COPY package.json package-lock.json .npmrc ./

RUN npm ci

FROM base AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN npm run build

FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

RUN mkdir .next
RUN chown nextjs:nodejs .next

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

COPY --from=builder --chown=nextjs:nodejs /app/db ./db
COPY --from=builder --chown=nextjs:nodejs /app/drizzle.config.ts ./drizzle.config.ts

COPY --from=deps /app/node_modules ./node_modules # any possible way to remove this?

ENV HOME=/home/nextjs
RUN mkdir -p /home/nextjs/.local/share && chown -R nextjs:nodejs /home/nextjs # this is for drizzle-kit, it needs this dir for drizzle studio. definitely a bug from drizzle-kit

RUN echo '#!/bin/sh' > /app/start.sh && \
echo 'set -e' >> /app/start.sh && \
echo 'npm run migrate' >> /app/start.sh && \ # it runs "drizzle-kit migrate" be better if i could just run migrate.ts/.mjs with node
echo 'exec node server.js' >> /app/start.sh && \
chmod +x /app/start.sh

USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["/app/start.sh"]
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
i was wondering if it's possible to just do it in a better (efficient) way
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
because drizzle-kit or tsx are in the node_modules
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
but i'm copying the node_modules into the docker which is not ideal
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
thank you! i finally made it to work with drizzle-kit
22 replies
DTDrizzle Team
Created by 0xsh on 10/3/2024 in #help
How to Drizzle Migrate?
i'd appreciate the response, thanks! could you please explain a bit more about mjs and how can i run the migrate.ts file?
22 replies