diff --git a/Dockerfile b/Dockerfile index cb1bbe7..536cb1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,28 @@ -FROM node:16 - +FROM node:16 as backend-ts-compiler WORKDIR /app - COPY package*.json ./ - -RUN npm i - +COPY tsconfig*.json ./ +RUN npm install COPY . . - RUN npm run build +FROM node:16 as frontend-compiler WORKDIR /app/frontend - -RUN npm i - +COPY --from=backend-ts-compiler /app/frontend/package*.json ./ +RUN npm install +COPY --from=backend-ts-compiler /app/frontend/ ./ RUN npm run build +FROM node:16 as strip-dev-deps WORKDIR /app +COPY --from=backend-ts-compiler /app/package*.json ./ +COPY --from=backend-ts-compiler /app/dist ./ +RUN npm install --only=production -CMD [ "/bin/sh", "-c", "npm run ream && npm run start" ] +FROM node:16 +WORKDIR /app +COPY --from=strip-dev-deps /app ./ +COPY --from=frontend-compiler /app/frontend/public ./frontend/public +RUN echo "JWT_SECRET=$(openssl rand -base64 256 | tr -d '\n')" > .env +USER node +CMD [ "/bin/sh", "-c", "node index.js db-init && node index.js" ] diff --git a/docker-compose.yml b/docker-compose.yml index b52ee6f..0b4434b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,10 +12,7 @@ services: build: . ports: - "5002:3000" - volumes: - - .:/app environment: - - JWT_SECRET=__jwtsecretgoeshere__ - PGUSER=waffle - PGHOST=waffle-postgres - PGPASSWORD=supersecretpassword11 diff --git a/tsconfig.json b/tsconfig.json index 10eb6ac..24131a5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,8 +6,8 @@ "target": "esnext", "module": "commonjs", "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, "strict": true, - "outDir": "./dist" + "outDir": "./dist", + "rootDir": "./src" } } \ No newline at end of file