forked from makeplane/plane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Dockerizing using nginx reverse proxy (makeplane#280)
* minor docker fixes * eslint config changes * dockerfile changes to backend and frontend * oauth enabled env flag * sentry enabled env flag * build: get alternatives for environment variables and static file storage * build: automatically generate random secret key if not provided * build: update docker compose for next url env add channels to requirements for asgi server and save files in local machine for docker environment * build: update nginx conf for backend base url update backend dockerfile to make way for static file uploads * feat: create a default user with given values else default values * chore: update docker python version and other dependency version in docker * build: update local settings file to run it in docker * fix: update script to run in default production setting * fix: env variable changes and env setup shell script added * Added Single Dockerfile to run the Entire plane application * docs build fixes --------- Co-authored-by: Narayana <[email protected]> Co-authored-by: pablohashescobar <[email protected]>
- Loading branch information
1 parent
33e2986
commit bdca84b
Showing
47 changed files
with
9,614 additions
and
11,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module.exports = { | ||
root: true, | ||
// This tells ESLint to load the config from the package `config` | ||
// extends: ["custom"], | ||
// This tells ESLint to load the config from the package `eslint-config-custom` | ||
extends: ["custom"], | ||
settings: { | ||
next: { | ||
rootDir: ["apps/*/"], | ||
rootDir: ["apps/*"], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
FROM node:18-alpine AS builder | ||
RUN apk add --no-cache libc6-compat | ||
RUN apk update | ||
# Set working directory | ||
WORKDIR /app | ||
|
||
RUN yarn global add turbo | ||
COPY . . | ||
|
||
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 | ||
|
||
# First install the dependencies (as they change less often) | ||
COPY .gitignore .gitignore | ||
COPY --from=builder /app/out/json/ . | ||
COPY --from=builder /app/out/yarn.lock ./yarn.lock | ||
RUN yarn install | ||
|
||
# Build the project | ||
COPY --from=builder /app/out/full/ . | ||
COPY turbo.json turbo.json | ||
|
||
RUN yarn turbo run build --filter=app | ||
|
||
|
||
FROM python:3.11.1-alpine3.17 AS backend | ||
|
||
# set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 | ||
|
||
WORKDIR /code | ||
|
||
RUN apk --update --no-cache add \ | ||
"libpq~=15" \ | ||
"libxslt~=1.1" \ | ||
"nodejs-current~=19" \ | ||
"xmlsec~=1.2" \ | ||
"nginx" \ | ||
"nodejs" \ | ||
"npm" \ | ||
"supervisor" | ||
|
||
COPY apiserver/requirements.txt ./ | ||
COPY apiserver/requirements ./requirements | ||
RUN apk add libffi-dev | ||
RUN apk --update --no-cache --virtual .build-deps add \ | ||
"bash~=5.2" \ | ||
"g++~=12.2" \ | ||
"gcc~=12.2" \ | ||
"cargo~=1.64" \ | ||
"git~=2" \ | ||
"make~=4.3" \ | ||
"postgresql13-dev~=13" \ | ||
"libc-dev" \ | ||
"linux-headers" \ | ||
&& \ | ||
pip install -r requirements.txt --compile --no-cache-dir \ | ||
&& \ | ||
apk del .build-deps | ||
|
||
# Add in Django deps and generate Django's static files | ||
COPY apiserver/manage.py manage.py | ||
COPY apiserver/plane plane/ | ||
COPY apiserver/templates templates/ | ||
|
||
COPY apiserver/gunicorn.config.py ./ | ||
RUN apk --update --no-cache add "bash~=5.2" | ||
COPY apiserver/bin ./bin/ | ||
|
||
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 | ||
|
||
# Don't run production as root | ||
RUN addgroup --system --gid 1001 plane | ||
RUN adduser --system --uid 1001 captain | ||
|
||
COPY --from=installer /app/apps/app/next.config.js . | ||
COPY --from=installer /app/apps/app/package.json . | ||
|
||
COPY --from=installer --chown=captain:plane /app/apps/app/.next/standalone ./ | ||
|
||
COPY --from=installer --chown=captain:plane /app/apps/app/.next/static ./apps/app/.next/static | ||
|
||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
# RUN rm /etc/nginx/conf.d/default.conf | ||
####################################################################### | ||
COPY nginx/nginx-single-docker-image.conf /etc/nginx/http.d/default.conf | ||
####################################################################### | ||
|
||
COPY nginx/supervisor.conf /code/supervisor.conf | ||
|
||
|
||
CMD ["supervisord","-c","/code/supervisor.conf"] | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
# Backend | ||
SECRET_KEY="<-- django secret -->" | ||
DJANGO_SETTINGS_MODULE="plane.settings.production" | ||
# Database | ||
DATABASE_URL=postgres://plane:plane@plane-db-1:5432/plane | ||
# Cache | ||
REDIS_URL=redis://redis:6379/ | ||
# SMPT | ||
EMAIL_HOST="<-- email smtp -->" | ||
EMAIL_HOST_USER="<-- email host user -->" | ||
EMAIL_HOST_PASSWORD="<-- email host password -->" | ||
|
||
# AWS | ||
AWS_REGION="<-- aws region -->" | ||
AWS_ACCESS_KEY_ID="<-- aws access key -->" | ||
AWS_SECRET_ACCESS_KEY="<-- aws secret acess key -->" | ||
AWS_S3_BUCKET_NAME="<-- aws s3 bucket name -->" | ||
|
||
SENTRY_DSN="<-- sentry dsn -->" | ||
WEB_URL="<-- frontend web url -->" | ||
|
||
# FE | ||
WEB_URL="localhost/" | ||
# OAUTH | ||
GITHUB_CLIENT_SECRET="<-- github secret -->" | ||
|
||
# Flags | ||
DISABLE_COLLECTSTATIC=1 | ||
DOCKERIZED=0 //True if running docker compose else 0 | ||
DOCKERIZED=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os, sys | ||
import uuid | ||
|
||
sys.path.append("/code") | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plane.settings.production") | ||
import django | ||
|
||
django.setup() | ||
|
||
from plane.db.models import User | ||
|
||
|
||
def populate(): | ||
default_email = os.environ.get("DEFAULT_EMAIL", "[email protected]") | ||
default_password = os.environ.get("DEFAULT_PASSWORD", "password123") | ||
|
||
if not User.objects.filter(email=default_email).exists(): | ||
user = User.objects.create(email=default_email, username=uuid.uuid4().hex) | ||
user.set_password(default_password) | ||
user.save() | ||
print("User created") | ||
|
||
print("Success") | ||
|
||
|
||
if __name__ == "__main__": | ||
populate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.