Skip to content

Commit

Permalink
docker
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 25, 2023
1 parent ab1e1a1 commit bf33254
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 2 additions & 0 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ server.register(require("@fastify/swagger"), {
url: "https://swagger.io",
description: "Find more info here",
},
mode: "static",
host: "localhost",
schemes: ["http"],
consumes: ["application/json"],
Expand All @@ -37,6 +38,7 @@ server.register(require("@fastify/swagger"), {
{ name: "user", description: "User related end-points" },
{ name: "code", description: "Code related end-points" },
],
exposeRoute: true,
definitions: {
User: {
type: "object",
Expand Down
4 changes: 1 addition & 3 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"docker": "yarn run migrate && yarn run generate && yarn run seed && yarn start",
"pm2-prod": "yarn run migrate && yarn run generate && yarn run seed && yarn run build && pm2 start npm --name \"next\" -- start"
"start": "next start"
},
"dependencies": {
"@headlessui/react": "^1.4.2",
Expand Down
2 changes: 1 addition & 1 deletion apps/client/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Login({}) {
const { setUser } = useUser();

async function postData() {
await fetch("http://localhost:5003/api/v1/auth/login", {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/login`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password }),
Expand Down
2 changes: 0 additions & 2 deletions apps/client/prisma/prisma.js

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
DB_USERNAME: "peppermint"
DB_PASSWORD: "1234"
DB_HOST: "peppermint_postgres"
API_PORT: 5003
API_URL: "http://localhost:5003"

volumes:
pgdata:
4 changes: 2 additions & 2 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
DB_USERNAME: "peppermint"
DB_PASSWORD: "1234"
DB_HOST: "peppermint_postgres"
API_PORT: 5003

API_URL: "http://localhost:5003"
volumes:
pgdata:
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
DB_USERNAME: "peppermint"
DB_PASSWORD: "1234"
DB_HOST: "peppermint_postgres"
API_PORT: 5003
API_URL: "http://localhost:5003"

volumes:
pgdata:
7 changes: 4 additions & 3 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RUN apt-get update && \
# Copy the package.json and package-lock.json files for both apps
COPY apps/api/package*.json ./apps/api/
COPY apps/client/package*.json ./apps/client/
COPY ./ecosystem.config.js ./ecosystem.config.js


RUN npm i -g prisma
RUN npm i -g typescript@latest -g --force
Expand All @@ -27,8 +29,7 @@ FROM node:lts 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

COPY --from=builder /app/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"]

1 change: 1 addition & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
env: {
NODE_ENV: "production",
PORT: 3000, // Change this to your desired port
API_URL: process.env.API_URL,
},
},
{
Expand Down

0 comments on commit bf33254

Please sign in to comment.