-
Hi guys, Can you guys help me deploy Worklenz on production environment using docker or docker-compose? I cloned the project but the documentation only shows Worklenz setup running on Development environment. If it's really good, can you guide me to configure Nginx, because after building frontend, the proxy-docker.config.json file will not work anymore. Many thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
@chamikaJ - would you like to assist? |
Beta Was this translation helpful? Give feedback.
-
@chamikaJ The thing i want:
======================================================================================= I did the following steps:
======================================================================================= What I got stuck:
======================================================================================= I use docker-compose to run application: `docker-compose.yml` file:services:
nginx:
build: ./nginx
ports:
- "80:80"
depends_on:
backend:
condition: service_started
frontend:
condition: service_started
frontend:
build:
context: ./worklenz-frontend
dockerfile: Dockerfile
container_name: worklenz_frontend
depends_on:
backend:
condition: service_started
backend:
build:
context: ./worklenz-backend
dockerfile: Dockerfile
container_name: worklenz_backend
environment:
- NODE_ENV=development
- PORT=3000
- SESSION_NAME=worklenz.sid
- SESSION_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- COOKIE_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- SOCKET_IO_CORS=http://frontend:4200
- SERVER_CORS=*
- DB_USER=worklenz_backend
- DB_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- DB_NAME=worklenz_db
- DB_HOST=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- DB_PORT=5432
- DB_MAX_CLIENTS=50
- GOOGLE_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- GOOGLE_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- GOOGLE_CALLBACK_URL="http://backend:3000/api/secure/google/verify"
- LOGIN_FAILURE_REDIRECT="/"
- LOGIN_SUCCESS_REDIRECT="http://frontend:4200/auth/authenticate"
- ANGULAR_DIST_DIR="../worklenz_frontend/dist/worklenz"
- ANGULAR_SRC_DIR="../worklenz_frontend"
- BACKEND_PUBLIC_DIR="../worklenz_backend/src/public"
- BACKEND_VIEWS_DIR="../worklenz_backend/src/views/admin"
- COMMIT_BUILD_IMMEDIATELY=true
- HOSTNAME=frontend:4200
- USE_PG_NATIVE=true
- JWT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- MAIL_HOST=smtp.gmail.com
- [email protected]
- MAIL_PASSWORD=fred nwhw bidr cbsw
- [email protected]
- REGION="us-west-2"
- BUCKET="BUCKET_NAME_HERE"
- S3_URL="S3_URL_HERE"
- S3_ACCESS_KEY_ID="S3_ACCESS_KEY_ID_HERE"
- S3_SECRET_ACCESS_KEY="S3_SECRET_ACCESS_KEY_HERE"
- AWS_REGION="us-west-2"
- AWS_ACCESS_KEY_ID="AWS_ACCESS_KEY_ID_HERE"
- AWS_SECRET_ACCESS_KEY="AWS_SECRET_ACCESS_KEY_HERE" `Dockerfile.yml` of nginx:FROM nginx:1.25.2-alpine
COPY conf.d /etc/nginx/conf.d
server {
listen 80;
server_name localhost;
client_max_body_size 150M;
client_body_buffer_size 16K;
location / {
proxy_pass http://frontend:80;
}
location /socket {
proxy_pass http://backend:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api {
proxy_pass http://backend:3000;
}
location /secure {
proxy_pass http://backend:3000;
}
} `Dockerfile.yml` of frontend:# Stage 1: Build the Angular app
FROM node:18-alpine3.17 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Stage 2: Serve the Angular app using nginx
FROM nginx:1.25.2-alpine
COPY default.conf /etc/nginx/conf.d/
COPY --from=build /app/dist/worklenz /usr/share/nginx/html
EXPOSE 80 `Dockerfile.yml` of Backend:# Stage 1: Build the Angular app
###################
# BUILD
###################
# Use the official Node.js 18 image as a base
FROM node:18 AS build
# Create and set the working directory
WORKDIR /usr/src/app
# Install global dependencies
RUN npm install -g ts-node typescript grunt grunt-cli
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install app dependencies
RUN npm ci
# Copy the rest of the application code
COPY . .
# Run the build script to compile TypeScript to JavaScript
RUN npm run build
###################
# RELEASE
###################
FROM node:18 AS production
USER node
WORKDIR /app
# Copy the bundled code from the build stage to the production image
COPY --chown=node:node --from=build /usr/src/app/worklenz-email-templates ./worklenz-email-templates
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/build ./build
COPY --chown=node:node --from=build /usr/src/app/release ./
COPY --chown=node:node --from=build /usr/src/app/package.json ./
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD [ "npm", "start" ] |
Beta Was this translation helpful? Give feedback.
-
If I want to separate frontend and backend independently, should I fill in the information in the `default.conf` config file in folder `conf.d`:server {
listen 80;
server_name mypage.com;
client_max_body_size 150M;
client_body_buffer_size 16K;
location / {
proxy_pass https://mypage.com;
}
location /socket {
proxy_pass https://mypage.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api {
proxy_pass https://mypage.com;
}
location /secure {
proxy_pass https://mypage.com;
}
} information in the `.env`:```yaml
|
Beta Was this translation helpful? Give feedback.
-
@Jacger We designed Worklenz to run as a proxy within the backend. In our production deployment process, we build the Angular frontend and then copy the build files using the While it is possible to separate the frontend and backend, achieving this would require some modifications to the API services. |
Beta Was this translation helpful? Give feedback.
You can compile your TypeScript files to JavaScript by running
npm run build
in the backend directory. Once the build completes without errors, start the backend server by runningnpm start
. Worklenz will be running on the port specified in your.env
file.