Skip to content

Commit

Permalink
Docker build refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mehallhm committed Nov 13, 2024
1 parent 31263ca commit 3adf0c3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/* \
Expand All @@ -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"]
8 changes: 2 additions & 6 deletions infrastructure/prod/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 3adf0c3

Please sign in to comment.