Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and code update for a working docker deployment #17

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = crlf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[Dockerfile]
indent_size = 4

[*.md]
max_line_length = off
trim_trailing_whitespace = false

[*.pug,]
indent_style = tab
indent_size = 4

[*.sql]
indent_style = space
indent_size = 4

[*.ts]
quote_type = single
82 changes: 82 additions & 0 deletions DOCKER_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Run App on Docker

Getting started with docker is a breeze! Follow these steps and you'll be contributing in no time.

## Requirements

- Docker v26 or newer - [Docker](https://www.docker.com/)

## Installation

**Clone the repository**

```bash
git clone https://github.com/Worklenz/worklenz.git
```

### Use Docker Compose

1. **Navigate to the project directory**

```bash
cd worklenz
```

2. **Run Compose in detach mode**

```bash
docker compose up -d
```

3. **Database Migration (Manual)**

```bash
docker compose exec backend bash
```

You should have bash access to backend container. To test connection to db and check for current active db.

```bash
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db
SELECT current_database();
```

If you have an output from the db, you can start running the migrations (one command at a time).

```bash
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db -f 1_tables.sql
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db -f 2_triggers.sql
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db -f 3_system-data.sql
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db -f 4_views.sql
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db -f 5_functions.sql
PGPASSWORD=worklenz_password psql -h db -U worklenz_user -d worklenz_db -f 6_user-permission.sql
```

and to verify

```bash
\dt
```

Exit and you are good to go.

```bash
http://localhost:4200
```

for frontend access

4. **Database Migration (Using PGAdmin)**

```bash
http://localhost:5050
```

for pgadmin access

```bash
username - admin@worklenz.com
password - worklenz_password
```

Add a connection using db access details and run the *.sql files.
116 changes: 68 additions & 48 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,68 @@
version: '3.8'

services:
frontend:
build:
context: ./worklenz-frontend
dockerfile: Dockerfile
container_name: worklenz_frontend
ports:
- "4200:4200"
volumes:
- ./worklenz-frontend:/app
networks:
- worklenz_network

backend:
build:
context: ./worklenz-backend
dockerfile: Dockerfile
container_name: worklenz_backend
ports:
- "3000:3000"
depends_on:
- db
environment:
- DATABASE_URL=postgres://worklenz_user:worklenz_password@db:5432/worklenz_db
volumes:
- ./worklenz-backend:/app
networks:
- worklenz_network

db:
image: postgres:15.6
container_name: worklenz_db
environment:
POSTGRES_USER: worklenz_user
POSTGRES_PASSWORD: worklenz_password
POSTGRES_DB: worklenz_db
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- worklenz_network

volumes:
postgres_data:

networks:
worklenz_network:
services:
frontend:
build:
context: ./worklenz-frontend
dockerfile: Dockerfile
args:
USER: worklenz
APP: worklenz
container_name: worklenz_frontend
ports:
- "4200:4200"
networks:
- worklenz_network
restart: always

backend:
build:
context: ./worklenz-backend
dockerfile: Dockerfile
args:
USER: worklenz
APP: worklenz
container_name: worklenz_backend
ports:
- "3000:3000"
depends_on:
- db
networks:
- worklenz_network
restart: always

db:
image: postgres:16.3
container_name: worklenz_db
environment:
POSTGRES_USER: worklenz_user
POSTGRES_PASSWORD: worklenz_password
POSTGRES_DB: worklenz_db
networks:
- worklenz_network
ports:
- "5432:5432"
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data

pgadmin:
image: dpage/pgadmin4
container_name: worklenz_pgadmin
depends_on:
- db
environment:
PGADMIN_DEFAULT_EMAIL: admin@worklenz.com
PGADMIN_DEFAULT_PASSWORD: worklenz_password
networks:
- worklenz_network
ports:
- "5050:80"
restart: always
volumes:
- pgadmin_data:/var/lib/pgadmin

volumes:
postgres_data:
pgadmin_data:

networks:
worklenz_network:
19 changes: 0 additions & 19 deletions worklenz-backend/.editorconfig

This file was deleted.

57 changes: 0 additions & 57 deletions worklenz-backend/.env.template

This file was deleted.