Skip to content

Commit 5c7382d

Browse files
fix: environment file missing for space (#3105)
* fix: environment file missing for space * dev: remove container name from the docker-compose local * dockerfile.dev modified for volumes * local dev fixes --------- Co-authored-by: Manish Gupta <[email protected]>
1 parent 1f8ae3a commit 5c7382d

10 files changed

+92
-46
lines changed

CONTRIBUTING.md

+4-25
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ The backend is a django project which is kept inside apiserver
3333
1. Clone the repo
3434

3535
```bash
36-
git clone https://github.com/makeplane/plane
37-
cd plane
36+
git clone https://github.com/makeplane/plane.git [folder-name]
37+
cd [folder-name]
3838
chmod +x setup.sh
3939
```
4040

@@ -44,33 +44,12 @@ chmod +x setup.sh
4444
./setup.sh
4545
```
4646

47-
3. Define `NEXT_PUBLIC_API_BASE_URL=http://localhost` in **web/.env** and **space/.env** file
47+
3. Start the containers
4848

4949
```bash
50-
echo "\nNEXT_PUBLIC_API_BASE_URL=http://localhost\n" >> ./web/.env
50+
docker compose -f docker-compose-local.yml up
5151
```
5252

53-
```bash
54-
echo "\nNEXT_PUBLIC_API_BASE_URL=http://localhost\n" >> ./space/.env
55-
```
56-
57-
4. Run Docker compose up
58-
59-
```bash
60-
docker compose up -d
61-
```
62-
63-
5. Install dependencies
64-
65-
```bash
66-
yarn install
67-
```
68-
69-
6. Run the web app in development mode
70-
71-
```bash
72-
yarn dev
73-
```
7453

7554
## Missing a Feature?
7655

apiserver/Dockerfile.dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ USER captain
4949
# Expose container port and run entry point script
5050
EXPOSE 8000
5151

52-
# CMD [ "./bin/takeoff" ]
52+
CMD [ "./bin/takeoff.local" ]
5353

apiserver/bin/takeoff.local

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -e
3+
python manage.py wait_for_db
4+
python manage.py migrate
5+
6+
# Create the default bucket
7+
#!/bin/bash
8+
9+
# Collect system information
10+
HOSTNAME=$(hostname)
11+
MAC_ADDRESS=$(ip link show | awk '/ether/ {print $2}' | head -n 1)
12+
CPU_INFO=$(cat /proc/cpuinfo)
13+
MEMORY_INFO=$(free -h)
14+
DISK_INFO=$(df -h)
15+
16+
# Concatenate information and compute SHA-256 hash
17+
SIGNATURE=$(echo "$HOSTNAME$MAC_ADDRESS$CPU_INFO$MEMORY_INFO$DISK_INFO" | sha256sum | awk '{print $1}')
18+
19+
# Export the variables
20+
export MACHINE_SIGNATURE=$SIGNATURE
21+
22+
# Register instance
23+
python manage.py register_instance $MACHINE_SIGNATURE
24+
# Load the configuration variable
25+
python manage.py configure_instance
26+
27+
# Create the default bucket
28+
python manage.py create_bucket
29+
30+
python manage.py runserver 0.0.0.0:8000 --settings=plane.settings.local
31+

docker-compose-local.yml

+4-17
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ volumes:
1212

1313
services:
1414
plane-redis:
15-
container_name: plane-redis
1615
image: redis:6.2.7-alpine
1716
restart: unless-stopped
1817
networks:
@@ -21,7 +20,6 @@ services:
2120
- redisdata:/data
2221

2322
plane-minio:
24-
container_name: plane-minio
2523
image: minio/minio
2624
restart: unless-stopped
2725
networks:
@@ -36,7 +34,6 @@ services:
3634
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY}
3735

3836
plane-db:
39-
container_name: plane-db
4037
image: postgres:15.2-alpine
4138
restart: unless-stopped
4239
networks:
@@ -53,16 +50,14 @@ services:
5350
PGDATA: /var/lib/postgresql/data
5451

5552
web:
56-
container_name: web
5753
build:
5854
context: .
5955
dockerfile: ./web/Dockerfile.dev
6056
restart: unless-stopped
6157
networks:
6258
- dev_env
6359
volumes:
64-
- .:/app
65-
command: yarn dev --filter=web
60+
- ./web:/app/web
6661
env_file:
6762
- ./web/.env
6863
depends_on:
@@ -73,22 +68,17 @@ services:
7368
build:
7469
context: .
7570
dockerfile: ./space/Dockerfile.dev
76-
container_name: space
7771
restart: unless-stopped
7872
networks:
7973
- dev_env
8074
volumes:
81-
- .:/app
82-
command: yarn dev --filter=space
83-
env_file:
84-
- ./space/.env
75+
- ./space:/app/space
8576
depends_on:
8677
- api
8778
- worker
8879
- web
8980

9081
api:
91-
container_name: api
9282
build:
9383
context: ./apiserver
9484
dockerfile: Dockerfile.dev
@@ -99,15 +89,14 @@ services:
9989
- dev_env
10090
volumes:
10191
- ./apiserver:/code
102-
command: /bin/sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000 --settings=plane.settings.local"
92+
# command: /bin/sh -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000 --settings=plane.settings.local"
10393
env_file:
10494
- ./apiserver/.env
10595
depends_on:
10696
- plane-db
10797
- plane-redis
10898

10999
worker:
110-
container_name: bgworker
111100
build:
112101
context: ./apiserver
113102
dockerfile: Dockerfile.dev
@@ -127,7 +116,6 @@ services:
127116
- plane-redis
128117

129118
beat-worker:
130-
container_name: beatworker
131119
build:
132120
context: ./apiserver
133121
dockerfile: Dockerfile.dev
@@ -147,10 +135,9 @@ services:
147135
- plane-redis
148136

149137
proxy:
150-
container_name: proxy
151138
build:
152139
context: ./nginx
153-
dockerfile: Dockerfile
140+
dockerfile: Dockerfile.dev
154141
restart: unless-stopped
155142
networks:
156143
- dev_env

nginx/Dockerfile.dev

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM nginx:1.25.0-alpine
2+
3+
RUN rm /etc/nginx/conf.d/default.conf
4+
COPY nginx.conf.dev /etc/nginx/nginx.conf.template
5+
6+
COPY ./env.sh /docker-entrypoint.sh
7+
8+
RUN chmod +x /docker-entrypoint.sh
9+
# Update all environment variables
10+
CMD ["/docker-entrypoint.sh"]

nginx/nginx-single-docker-image.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ server {
1818
proxy_set_header Host $host;
1919
proxy_set_header X-Real-IP $remote_addr;
2020
}
21-
location /space/ {
21+
location /spaces/ {
2222
proxy_pass http://localhost:4000/;
2323
proxy_set_header Host $host;
2424
proxy_set_header X-Real-IP $remote_addr;

nginx/nginx.conf.dev

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
events {
2+
}
3+
4+
http {
5+
sendfile on;
6+
7+
server {
8+
listen 80;
9+
root /www/data/;
10+
access_log /var/log/nginx/access.log;
11+
12+
client_max_body_size ${FILE_SIZE_LIMIT};
13+
14+
add_header X-Content-Type-Options "nosniff" always;
15+
add_header Referrer-Policy "no-referrer-when-downgrade" always;
16+
add_header Permissions-Policy "interest-cohort=()" always;
17+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
18+
19+
location / {
20+
proxy_pass http://web:3000/;
21+
}
22+
23+
location /api/ {
24+
proxy_pass http://api:8000/api/;
25+
}
26+
27+
location /spaces/ {
28+
rewrite ^/spaces/?$ /spaces/login break;
29+
proxy_pass http://space:4000/spaces/;
30+
}
31+
32+
location /${BUCKET_NAME}/ {
33+
proxy_pass http://plane-minio:9000/uploads/;
34+
}
35+
}
36+
}

setup.sh

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export LC_ALL=C
66
export LC_CTYPE=C
77

88
cp ./web/.env.example ./web/.env
9-
cp ./space/.env.example ./space/.env
109
cp ./apiserver/.env.example ./apiserver/.env
1110

1211
# Generate the SECRET_KEY that will be used by django

space/Dockerfile.dev

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ WORKDIR /app
77
COPY . .
88
RUN yarn global add turbo
99
RUN yarn install
10-
EXPOSE 3000
10+
EXPOSE 4000
11+
ENV NEXT_PUBLIC_DEPLOY_WITH_NGINX=1
12+
13+
VOLUME [ "/app/node_modules", "/app/space/node_modules"]
1114
CMD ["yarn","dev", "--filter=space"]

web/Dockerfile.dev

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ COPY . .
88
RUN yarn global add turbo
99
RUN yarn install
1010
EXPOSE 3000
11+
VOLUME [ "/app/node_modules", "/app/web/node_modules" ]
1112
CMD ["yarn", "dev", "--filter=web"]

0 commit comments

Comments
 (0)