Skip to content

Commit

Permalink
docker
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 24, 2023
1 parent be5927d commit debf27d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 53 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ const start = async () => {
try {
// Run prisma generate and migrate commands before starting the server
await new Promise<void>((resolve, reject) => {
exec("npx prisma generate", (err, stdout, stderr) => {
exec("npx prisma migrate deploy", (err, stdout, stderr) => {
if (err) {
console.error(err);
reject(err);
}
console.log(stdout);
console.error(stderr);

exec("npx prisma migrate dev", (err, stdout, stderr) => {
exec("npx prisma generate", (err, stdout, stderr) => {
if (err) {
console.error(err);
reject(err);
Expand Down
21 changes: 11 additions & 10 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
# Use the official Node.js image as the base image
FROM node:18-alpine
FROM node:lts-alpine AS builder

# Set the working directory inside the container
WORKDIR /app

RUN apk update
RUN apk add --no-cache bash
RUN apk --no-cache --virtual build-dependencies add make g++ libc6-compat python3

# Set the working directory inside the container
WORKDIR /app

# Copy the package.json and package-lock.json files for both apps
COPY apps/api/package*.json ./apps/api/
COPY ./ecosystem.config.js ./ecosystem.config.js
COPY apps/client/package*.json ./apps/client/

RUN npm i -g prisma
RUN npm i -g typescript@latest -g --force


# Copy the source code for both apps
COPY apps/api ./apps/api
COPY apps/client ./apps/client

RUN npm cache clean --force

RUN cd apps/api && npm install --production
RUN cd apps/api && npm i --save-dev @types/node && npm run build

RUN cd apps/client && yarn install --production --ignore-scripts --prefer-offline --network-timeout 1000000
RUN cd apps/client && yarn add --dev typescript @types/node --network-timeout 1000000 && yarn build

FROM node:lts-alpine AS runner

COPY --from=builder /app/apps/api/ ./apps/api/
COPY --from=builder /app/apps/client ./apps/client
COPY ./ecosystem.config.js ./ecosystem.config.js


# Expose the ports for both apps
EXPOSE 3000 5003
Expand All @@ -37,5 +38,5 @@ EXPOSE 3000 5003
RUN npm install -g pm2

# Start both apps using PM2
CMD ["pm2-runtime", "ecosystem.config.js"]
CMD ["pm2-runtime", "ecosystem.config .js"]

41 changes: 0 additions & 41 deletions dockerfile.test

This file was deleted.

0 comments on commit debf27d

Please sign in to comment.