Move migrations to separate app

This commit is contained in:
Darren Clarke 2024-08-07 16:05:26 +02:00
parent 87724bb7b8
commit c47223f5e9
21 changed files with 55 additions and 815 deletions

View file

@ -6,7 +6,7 @@ RUN mkdir -p ${APP_DIR}/
RUN npm i -g turbo
WORKDIR ${APP_DIR}
COPY . .
RUN turbo prune --scope=@link-stack/bridge-frontend --docker
RUN turbo prune --scope=@link-stack/bridge-frontend --scope=@link-stack/bridge-migrations --docker
FROM base AS installer
ARG APP_DIR=/opt/bridge-frontend
@ -18,7 +18,7 @@ RUN npm ci
COPY --from=builder ${APP_DIR}/out/full/ .
RUN npm i -g turbo
RUN turbo run build --filter=@link-stack/bridge-frontend
RUN turbo run build --filter=@link-stack/bridge-frontend --filter=@link-stack/bridge-migrations
FROM base AS runner
ARG APP_DIR=/opt/bridge-frontend
@ -36,6 +36,7 @@ RUN mkdir -p ${APP_DIR}
WORKDIR ${APP_DIR}
COPY --from=installer ${APP_DIR}/node_modules/ ./node_modules/
COPY --from=installer ${APP_DIR}/apps/bridge-frontend/ ./apps/bridge-frontend/
COPY --from=installer ${APP_DIR}/apps/bridge-migrations/ ./apps/bridge-migrations/
COPY --from=installer ${APP_DIR}/package.json ./package.json
RUN chown -R node:node ${APP_DIR}/
WORKDIR ${APP_DIR}/apps/bridge-frontend/

View file

@ -2,6 +2,6 @@
set -e
echo "running migrations"
npm run migrate:up:all
(cd ../bridge-migrations/ && npm run migrate:up:all)
echo "starting bridge-frontend"
exec dumb-init npm run start

View file

@ -0,0 +1,24 @@
{
"name": "@link-stack/bridge-migrations",
"version": "2.1.0",
"type": "module",
"scripts": {
"migrate:up:all": "tsx migrate.ts up:all",
"migrate:up:one": "tsx migrate.ts up:one",
"migrate:down:all": "tsx migrate.ts down:all",
"migrate:down:one": "tsx migrate.ts down:one"
},
"dependencies": {
"dotenv": "^16.4.5",
"kysely": "0.26.1",
"pg": "^8.12.0",
"tsx": "^4.16.5"
},
"devDependencies": {
"@types/node": "^22",
"@types/pg": "^8.11.6",
"@link-stack/eslint-config": "*",
"@link-stack/typescript-config": "*",
"typescript": "^5"
}
}

View file

@ -6,7 +6,7 @@ RUN mkdir -p ${APP_DIR}/
RUN npm i -g turbo
WORKDIR ${APP_DIR}
COPY . .
RUN turbo prune --scope=@link-stack/link --docker
RUN turbo prune --scope=@link-stack/link --scope=@link-stack/bridge-migrations --docker
FROM base AS installer
ARG APP_DIR=/opt/link
@ -18,7 +18,7 @@ RUN npm ci
COPY --from=builder ${APP_DIR}/out/full/ .
RUN npm i -g turbo
RUN turbo run build --filter=@link-stack/link
RUN turbo run build --filter=@link-stack/link --filter=@link-stack/bridge-migrations
FROM base AS runner
ARG APP_DIR=/opt/link
@ -39,6 +39,7 @@ USER node
WORKDIR ${APP_DIR}
COPY --from=installer ${APP_DIR}/node_modules/ ./node_modules/
COPY --from=installer ${APP_DIR}/apps/link/ ./apps/link/
COPY --from=installer ${APP_DIR}/apps/bridge-migrations/ ./apps/bridge-migrations/
COPY --from=installer ${APP_DIR}/package.json ./package.json
USER root
WORKDIR ${APP_DIR}/apps/link/

View file

@ -1,6 +1,7 @@
#!/bin/bash
set -e
echo "running migrations"
(cd ../bridge-migrations/ && npm run migrate:up:all)
echo "starting link"
exec dumb-init npm run start