Skip to content

Commit

Permalink
chore: docker setup (makeplane#1136)
Browse files Browse the repository at this point in the history
* chore: update docker environment variables and compose file for better readability

* dev: update single dockerfile

* dev: update WEB_URL configuration

* dev: move database settings to environment variable

* chore: remove port configuration from default compose file

* dev: update example env to add EMAIL_FROM and default values for AWS
  • Loading branch information
pablohashescobar authored May 26, 2023
1 parent 16604dd commit b632143
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 195 deletions.
15 changes: 11 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ EMAIL_HOST=""
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=""
EMAIL_PORT=587
EMAIL_FROM="Team Plane <team@mailer.plane.so>"

# AWS Settings
AWS_REGION=""
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
AWS_S3_BUCKET_NAME=""
AWS_ACCESS_KEY_ID="access-key"
AWS_SECRET_ACCESS_KEY="secret-key"
AWS_S3_BUCKET_NAME="uploads"
AWS_S3_ENDPOINT_URL=""

# GPT settings
OPENAI_API_KEY=""
GPT_ENGINE=""

# Auto generated and Required
# Github
GITHUB_CLIENT_SECRET="" # For fetching release notes

# Settings related to Docker
DOCKERIZED=1

# Auto generated and Required that will be generated from setup.sh
13 changes: 3 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN turbo prune --scope=app --docker
# Add lockfile and package.json's of isolated subworkspace
FROM node:18-alpine AS installer


RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
Expand Down Expand Up @@ -44,6 +43,8 @@ FROM python:3.11.1-alpine3.17 AS backend
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV DJANGO_SETTINGS_MODULE plane.settings.production
ENV DOCKERIZED 1

WORKDIR /code

Expand Down Expand Up @@ -88,11 +89,6 @@ RUN chmod +x ./bin/takeoff ./bin/worker
RUN chmod -R 777 /code

# Expose container port and run entry point script
EXPOSE 8000
EXPOSE 3000
EXPOSE 80



WORKDIR /app

Expand Down Expand Up @@ -126,9 +122,6 @@ COPY start.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/replace-env-vars.sh
RUN chmod +x /usr/local/bin/start.sh

EXPOSE 80

CMD ["supervisord","-c","/code/supervisor.conf"]




8 changes: 4 additions & 4 deletions apiserver/plane/api/views/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def post(self, request, slug):

serializer.save(workspace_id=request.user.last_workspace_id)
response_data = serializer.data
if settings.DOCKERIZED and "minio:9000" in response_data["asset"]:
response_data["asset"] = response_data["asset"].replace("minio:9000", settings.WEB_URL)
if settings.DOCKERIZED and settings.AWS_S3_ENDPOINT_URL in response_data["asset"]:
response_data["asset"] = response_data["asset"].replace(settings.AWS_S3_ENDPOINT_URL, settings.WEB_URL)
return Response(response_data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
Expand Down Expand Up @@ -86,8 +86,8 @@ def post(self, request):
if serializer.is_valid():
serializer.save()
response_data = serializer.data
if settings.DOCKERIZED and "minio:9000" in response_data["asset"]:
response_data["asset"] = response_data["asset"].replace("minio:9000", settings.WEB_URL)
if settings.DOCKERIZED and settings.AWS_S3_ENDPOINT_URL in response_data["asset"]:
response_data["asset"] = response_data["asset"].replace(settings.AWS_S3_ENDPOINT_URL, settings.WEB_URL)
return Response(response_data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,8 @@ def post(self, request, slug, project_id, issue_id):
if serializer.is_valid():
serializer.save(project_id=project_id, issue_id=issue_id)
response_data = serializer.data
if settings.DOCKERIZED and "minio:9000" in response_data["asset"]:
response_data["asset"] = response_data["asset"].replace("minio:9000", settings.WEB_URL)
if settings.DOCKERIZED and settings.AWS_S3_ENDPOINT_URL in response_data["asset"]:
response_data["asset"] = response_data["asset"].replace(settings.AWS_S3_ENDPOINT_URL, settings.WEB_URL)
issue_activity.delay(
type="attachment.activity.created",
requested_data=None,
Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/bgtasks/email_verification_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def email_verification(first_name, email, token, current_site):

try:
realtivelink = "/request-email-verification/" + "?token=" + str(token)
abs_url = "http://" + current_site + realtivelink
abs_url = current_site + realtivelink

from_email_string = settings.EMAIL_FROM

Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/bgtasks/forgot_password_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def forgot_password(first_name, email, uidb64, token, current_site):

try:
realtivelink = f"/email-verify/?uidb64={uidb64}&token={token}/"
abs_url = "http://" + current_site + realtivelink
abs_url = current_site + realtivelink

from_email_string = settings.EMAIL_FROM

Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/bgtasks/magic_link_code_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def magic_link(email, key, token, current_site):
try:
realtivelink = f"/magic-sign-in/?password={token}&key={key}"
abs_url = "http://" + current_site + realtivelink
abs_url = current_site + realtivelink

from_email_string = settings.EMAIL_FROM

Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/bgtasks/project_invitation_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def project_invitation(email, project_id, token, current_site):
)

relativelink = f"/project-member-invitation/{project_member_invite.id}"
abs_url = "http://" + current_site + relativelink
abs_url = current_site + relativelink

from_email_string = settings.EMAIL_FROM

Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/bgtasks/workspace_invitation_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def workspace_invitation(email, workspace_id, token, current_site, invitor):
realtivelink = (
f"/workspace-member-invitation/{workspace_member_invite.id}?email={email}"
)
abs_url = "http://" + current_site + realtivelink
abs_url = current_site + realtivelink

from_email_string = settings.EMAIL_FROM

Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
if DOCKERIZED:
REDIS_URL = os.environ.get("REDIS_URL")

WEB_URL = os.environ.get("WEB_URL", "localhost:3000")
WEB_URL = os.environ.get("WEB_URL", "http://localhost:3000")
PROXY_BASE_URL = os.environ.get("PROXY_BASE_URL", False)

ANALYTICS_SECRET_KEY = os.environ.get("ANALYTICS_SECRET_KEY", False)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/plane/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
# The name of the bucket to store files in.
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_S3_BUCKET_NAME", "uploads")
# The full URL to the S3 endpoint. Leave blank to use the default region URL.
AWS_S3_ENDPOINT_URL = os.environ.get("AWS_S3_ENDPOINT_URL", "http://minio:9000")
AWS_S3_ENDPOINT_URL = os.environ.get("AWS_S3_ENDPOINT_URL", "http://plane-minio:9000")
# Default permissions
AWS_DEFAULT_ACL = "public-read"
AWS_QUERYSTRING_AUTH = False
Expand Down Expand Up @@ -223,7 +223,7 @@
}


WEB_URL = os.environ.get("WEB_URL")
WEB_URL = os.environ.get("WEB_URL", "https://app.plane.so")

PROXY_BASE_URL = os.environ.get("PROXY_BASE_URL", False)

Expand Down
56 changes: 31 additions & 25 deletions docker-compose-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.8"
services:
plane-web:
container_name: planefrontend
image: makeplane/plane-frontend:0.6
image: makeplane/plane-frontend:latest
restart: always
command: /usr/local/bin/start.sh
environment:
Expand All @@ -19,12 +19,12 @@ services:

plane-api:
container_name: planebackend
image: makeplane/plane-backend:0.6
image: makeplane/plane-backend:latest
restart: always
command: ./bin/takeoff
environment:
DJANGO_SETTINGS_MODULE: plane.settings.production
DATABASE_URL: postgres://plane:xyzzyspoon@plane-db:5432/plane
DATABASE_URL: postgres://${PGUSER}:${PGPASSWORD}@plane-db:5432/plane
REDIS_URL: redis://plane-redis:6379/
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_HOST_USER: ${EMAIL_HOST_USER}
Expand All @@ -33,7 +33,7 @@ services:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
WEB_URL: localhost/
WEB_URL: ${WEB_URL}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
DISABLE_COLLECTSTATIC: 1
DOCKERIZED: 1
Expand All @@ -48,12 +48,12 @@ services:

plane-worker:
container_name: planerqworker
image: makeplane/plane-worker:0.6
image: makeplane/plane-worker:latest
restart: always
command: ./bin/worker
environment:
DJANGO_SETTINGS_MODULE: plane.settings.production
DATABASE_URL: postgres://plane:xyzzyspoon@plane-db:5432/plane
DATABASE_URL: postgres://${PGUSER}:${PGPASSWORD}@plane-db:5432/plane
REDIS_URL: redis://plane-redis:6379/
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_HOST_USER: ${EMAIL_HOST_USER}
Expand All @@ -62,7 +62,7 @@ services:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
WEB_URL: localhost/
WEB_URL: ${WEB_URL}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
DISABLE_COLLECTSTATIC: 1
DOCKERIZED: 1
Expand All @@ -80,9 +80,9 @@ services:
restart: always
command: postgres -c 'max_connections=1000'
environment:
POSTGRES_USER: plane
POSTGRES_USER: ${PGUSER}
POSTGRES_DB: plane
POSTGRES_PASSWORD: xyzzyspoon
POSTGRES_PASSWORD: ${PGPASSWORD}
volumes:
- pgdata:/var/lib/postgresql/data

Expand All @@ -94,25 +94,30 @@ services:
- redisdata:/data

plane-minio:
container_name: plane-minio
image: minio/minio
environment:
MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY}
command: server /export --console-address ":9090"
container_name: plane-minio
image: minio/minio
volumes:
- uploads:/export
environment:
MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID}
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY}
command: server /export --console-address ":9090"
ports:
- 9000:9000

createbuckets:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add plane-minio http://minio:9000 \$AWS_ACCESS_KEY_ID \$AWS_SECRET_ACCESS_KEY;
/usr/bin/mc mb plane-minio/\$AWS_S3_BUCKET_NAME;
/usr/bin/mc anonymous set download plane-minio/\$AWS_S3_BUCKET_NAME;
exit 0;
"
image: minio/mc
depends_on:
- plane-minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add plane-minio http://plane-minio:9000 \$AWS_ACCESS_KEY_ID \$AWS_SECRET_ACCESS_KEY;
/usr/bin/mc mb plane-minio/\$AWS_S3_BUCKET_NAME;
/usr/bin/mc anonymous set download plane-minio/\$AWS_S3_BUCKET_NAME;
exit 0;
"
# Comment this if you already have a reverse proxy running
nginx:
container_name: nginx
build:
Expand All @@ -128,3 +133,4 @@ services:
volumes:
pgdata:
redisdata:
uploads:
Loading

0 comments on commit b632143

Please sign in to comment.