diff --git a/.env.template b/.env.template index 86d7b90..cfb8549 100644 --- a/.env.template +++ b/.env.template @@ -1,5 +1,5 @@ PORT=5000 MONGODB_URI=mongodb://localhost:27017/friendship-network JWT_SECRET=your_jwt_secret_key_change_this -CLIENT_URL=http://localhost:3000 +APP_URL=http://localhost:3000 ENABLE_REGISTRATION=true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9a0260a..a5db6ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,4 +38,10 @@ COPY --from=frontend-builder /frontend/dist/ /app/frontend/dist COPY --from=backend-builder /app/dist /app/dist COPY package.json . +ENV PORT=80 +ENV MONGODB_URI=mongodb://db:27017/friendship-network +ENV JWT_SECRET=7hPqh6pS91WCQY +ENV APP_URL=http://localhost:80 +ENV ENABLE_REGISTRATION=true + CMD ["yarn", "run", "start"] diff --git a/docker-compose.traefik.yml b/docker-compose.traefik.yml new file mode 100644 index 0000000..6f8ecd6 --- /dev/null +++ b/docker-compose.traefik.yml @@ -0,0 +1,33 @@ +networks: + internal: + internal: true + traefik: + external: true + +services: + relnet: + image: github.com/philipredstone/relnet:latest + build: . + networks: + - internal + - traefik + environment: + - PORT=80 + - MONGODB_URI=mongodb://relnet-db:27017/friendship-network + - JWT_SECRET=your_jwt_secret_key_change_this + - APP_URL=http://localhost:80 + - ENABLE_REGISTRATION=true + labels: + - "traefik.enable=true" + - "traefik.http.routers.relnet.rule=Host(`relnet`)" + - "traefik.http.routers.relnet.entrypoints=websecure" + - "traefik.http.routers.relnet.tls.certresolver=letsencrypt" + - "traefik.http.services.relnet.loadbalancer.server.port=80" + + relnet-db: + image: mongo:latest + networks: + - internal + restart: always + volumes: + - db:/data/db \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..03d0aa4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +networks: + internal: + internal: true + +services: + relnet: + image: github.com/philipredstone/relnet:latest + build: . + ports: + - "80:80" + networks: + - internal + environment: + - PORT=80 + - MONGODB_URI=mongodb://relnet-db:27017/friendship-network + - JWT_SECRET=your_jwt_secret_key_change_this + - APP_URL=http://localhost:80 + - ENABLE_REGISTRATION=true + + relnet-db: + image: mongo:latest + networks: + - internal + restart: always + volumes: + - db:/data/db \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index c6cf5d4..fc55309 100644 --- a/src/app.ts +++ b/src/app.ts @@ -17,7 +17,7 @@ app.use(express.json()); app.use(cookieParser()); app.use( cors({ - origin: process.env.CLIENT_URL || 'http://localhost:3000', + origin: process.env.APP_URL || 'http://localhost:3000', credentials: true, }) );