Update Dockerfile and add docker-compose for standalone and traefik

This commit is contained in:
Tobias Hopp 2025-04-15 15:56:42 +02:00
parent d6e1162631
commit 3e3b8930b5
5 changed files with 67 additions and 2 deletions

View File

@ -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

View File

@ -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"]

View File

@ -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

26
docker-compose.yml Normal file
View File

@ -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

View File

@ -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,
})
);