-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload API Prep Part 1: Add db-migrate, extract config.ts, change tsoa entrypoint and use tsx in prod #33
Changes from 10 commits
75a17b4
d12d1bf
976fa81
32f566c
526e193
229ae05
0c2779a
9dbf70c
bde959a
a6af53e
0923e6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ POSTGRES_PASSWORD=badgehub | |
PGADMIN_DEFAULT_PASSWORD=badgehub | ||
[email protected] | ||
|
||
JWT_SIGNING_KEY="!!HackThePlanet!!" | ||
NODE_ENV=development | ||
|
||
JWT_SIGNING_KEY="!!HackThePlanet!!" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
# Build Stage | ||
FROM node:22-bookworm-slim AS build | ||
|
||
WORKDIR /home/node/app | ||
|
||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
|
||
# Prod stage | ||
FROM node:22-bookworm-slim | ||
|
||
WORKDIR /home/node/app | ||
ENV NODE_ENV=production | ||
|
||
# Copy only needed files | ||
COPY --chown=node:node --from=build /home/node/app/dist ./dist | ||
COPY --chown=node:node --from=build /home/node/app/public ./public | ||
COPY --chown=node:node --from=build /home/node/app/package*.json ./ | ||
COPY --chown=node:node ./package*.json . | ||
|
||
RUN npm ci --only=production --ignore-scripts | ||
|
||
COPY process.json . | ||
COPY --chown=node:node process.json . | ||
RUN mkdir -p /home/node/.pm2 /home/node/app/logs /home/node/app/pids && chown -R node:node /home/node/.pm2 /home/node/app/logs | ||
|
||
# db-migrate stuff | ||
COPY --chown=node:node migrations ./migrations | ||
COPY --chown=node:node database.json . | ||
|
||
COPY --chown=node:node ./public ./public | ||
COPY --chown=node:node ./src ./src | ||
|
||
USER node | ||
EXPOSE 8081 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, but if you put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I copied this over from the original dockedfile here, but would indeed be interesting to check if this is actually needed. |
||
CMD ["./node_modules/pm2/bin/pm2-runtime", "process.json"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"defaultEnv": "pg-from-env", | ||
"pg-from-env": { | ||
"driver": "pg", | ||
"host": { "ENV": "POSTGRES_HOST" }, | ||
"database": { "ENV": "POSTGRES_DB" }, | ||
"user": { "ENV": "POSTGRES_USER" }, | ||
"password": { "ENV": "POSTGRES_PASSWORD" }, | ||
"port": "5432", | ||
"schema": "badgehub" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ volumes: | |
networks: | ||
badgehub_network: | ||
name: badgehub_network | ||
external: true | ||
external: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"description": "This package.json file is picked up by db-migrate and that is needed because the js files generated by db-migrate are commonjs", | ||
"type": "commonjs" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait why are we removing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no build anymore, we just run straight with tsx.
Here the commit and a bit about the rationale: