build: create frontend and backend dockerfiles docker compose and scripts

This commit is contained in:
pablohashescobar 2022-12-01 19:18:10 +05:30
parent 26ec1e8c15
commit 949b62d13f
151 changed files with 186 additions and 1 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
.git
*.pyc
.env
venv
node_modules
npm-debug.log

56
apiserver/Dockerfile Normal file
View File

@ -0,0 +1,56 @@
FROM python:3.8.14-alpine3.16 AS backend
ENV PYTHONUNBUFFERED 1
WORKDIR /code
RUN apk --update --no-cache add \
"libpq~=14" \
"libxslt~=1.1" \
"nodejs-current~=18" \
"xmlsec~=1.2"
COPY requirements.txt ./
COPY requirements ./requirements
RUN apk --update --no-cache --virtual .build-deps add \
"bash~=5.1" \
"g++~=11.2" \
"gcc~=11.2" \
"cargo~=1.60" \
"git~=2" \
"make~=4.3" \
"libffi-dev~=3.4" \
"libxml2-dev~=2.9" \
"libxslt-dev~=1.1" \
"xmlsec-dev~=1.2" \
"postgresql13-dev~=13" \
"libmaxminddb~=1.6" \
&& \
pip install -r requirements.txt --compile --no-cache-dir \
&& \
apk del .build-deps
RUN addgroup -S plane && \
adduser -S captain -G plane
RUN chown captain.plane /code
USER captain
# Add in Django deps and generate Django's static files
COPY manage.py manage.py
COPY plane plane/
COPY templates templates/
COPY gunicorn.config.py ./
COPY bin/takeoff ./takeoff
USER captain
# Expose container port and run entry point script
EXPOSE 8000
# ENTRYPOINT [ "./takeoff" ]
CMD python manage.py migrate && python manage.py rqworker & exec gunicorn plane.wsgi -k gthread --workers 8 --bind 0.0.0.0:8000 --config gunicorn.config.py --max-requests 10000 --max-requests-jitter 1000 --access-logfile -

6
apiserver/bin/takeoff Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
python manage.py migrate
python manage.py rqworker &
exec gunicorn plane.wsgi -k gthread --workers 8 --bind 0.0.0.0:8000 --config gunicorn.config.py --max-requests 10000 --max-requests-jitter 1000 --access-logfile -

View File

@ -0,0 +1,6 @@
from psycogreen.gevent import patch_psycopg
def post_fork(server, worker):
patch_psycopg()
worker.log.info("Made Psycopg2 Green")

View File

@ -7,4 +7,6 @@ django-storages==1.12.3
boto==2.49.0
django-anymail==8.5
twilio==7.8.2
django-debug-toolbar==3.2.4
django-debug-toolbar==3.2.4
gevent==22.10.2
psycogreen==1.0.2

47
apps/plane/Dockerfile Normal file
View File

@ -0,0 +1,47 @@
FROM node:alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY ./apps ./apps
COPY ./package.json ./package.json
COPY ./.eslintrc.json ./.eslintrc.json
COPY ./turbo.json ./turbo.json
COPY ./yarn.lock ./yarn.lock
RUN turbo prune --scope=plane --docker
# Add lockfile and package.json's of isolated subworkspace
FROM node: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=plane...
FROM node:alpine AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/plane/next.config.js .
COPY --from=installer /app/apps/plane/package.json .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/plane/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/plane/.next/static ./apps/plane/.next/static
CMD node apps/plane/server.js

View File

@ -1,10 +1,18 @@
/** @type {import('next').NextConfig} */
const path = require("path");
const nextConfig = {
reactStrictMode: false,
swcMinify: true,
images: {
domains: ["vinci-web.s3.amazonaws.com"],
},
output: 'standalone',
experimental: {
outputFileTracingRoot: path.join(__dirname, "../../"),
transpilePackages: ["ui"],
},
};
module.exports = nextConfig;

Some files were not shown because too many files have changed in this diff Show More