diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 8fbd946d..e0dc5e66 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -57,7 +57,7 @@ jobs: run: curl localhost:4000/.well-known/apollo/server-health - name: Run a custom scrape (shouldn't take more than ~5 minutes) - run: docker exec test sh -c "LOG_LEVEL=VERBOSE CUSTOM_SCRAPE=true TERMS_TO_SCRAPE=202140 yarn prod:scrape" + run: docker exec test sh -c "LOG_LEVEL=VERBOSE CUSTOM_SCRAPE=true TERMS_TO_SCRAPE=202140 node scrapers/main.js" #### If these start failing, it might not be our fault ## Since this test uses live data, there is a chance it could change @@ -100,7 +100,7 @@ jobs: "SELECT name FROM courses WHERE subject = 'CS' and class_id = '3500';" | grep "Object" - name: Run the updater ONLY ONCE, so that it scrapes missing classes - run: docker exec test sh -c "LOG_LEVEL=VERBOSE CUSTOM_SCRAPE=true UPDATE_ONLY_ONCE=true TERMS_TO_SCRAPE=202140 yarn prod:updater" + run: docker exec test sh -c "LOG_LEVEL=VERBOSE CUSTOM_SCRAPE=true UPDATE_ONLY_ONCE=true TERMS_TO_SCRAPE=202140 node services/updater.js" # This should take 5 minutes MAX. # In the scrape step, we used `CUSTOM_SCRAPE=true`. That limits what courses are being scraped - see `scrapers/filter` for more details. # We need to use that here as well. diff --git a/Dockerfile b/Dockerfile index 2be91f83..2a642a95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,16 @@ COPY infrastructure/prod /app COPY babel.config.json /app RUN yarn build -RUN rm -rf node_modules + +FROM node:22-alpine AS dist +WORKDIR /dist +RUN corepack enable + +COPY --from=build /app/dist . + +# TODO: This should be a `yarn workspaces focus --production` but +# the dev and non-dev deps are a tangled mess rn +RUN yarn workspaces focus # Get RDS Certificate RUN apk update && apk add wget && rm -rf /var/cache/apk/* \ @@ -33,7 +42,7 @@ ENV dbCertPath=/app/rds-ca-2019-root.pem ENV NODE_ENV=prod -ENTRYPOINT ["/app/entrypoint.sh"] +ENTRYPOINT ["/dist/entrypoint.sh"] EXPOSE 4000 8080 -CMD ["node", "dist/graphql/index.js"] +CMD ["node", "graphql/index.js"] diff --git a/infrastructure/prod/entrypoint.sh b/infrastructure/prod/entrypoint.sh index 90a01405..8ff45ce1 100755 --- a/infrastructure/prod/entrypoint.sh +++ b/infrastructure/prod/entrypoint.sh @@ -1,11 +1,7 @@ #!/bin/sh -cd dist -# TODO: This should be a `yarn workspaces focus --production` but -# the dev and non-dev deps are a tangled mess rn -yarn workspaces focus -yarn prod:db:migrate +# Run a production prisma migration +yarn prisma migrate deploy --preview-feature yarn db:refresh -cd .. exec "$@"