feat: monoimage

This commit is contained in:
bingus 2023-12-11 12:23:00 -06:00
parent 0c5ddeac85
commit e7fe19890d
Signed by: orion
GPG Key ID: 6D4165AE4C928719
46 changed files with 2489 additions and 274 deletions

55
.env
View File

@ -1,55 +0,0 @@
NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS=
NEXT_PUBLIC_GOOGLE_CLIENTID=""
NEXT_PUBLIC_GITHUB_ID=""
NEXT_PUBLIC_GITHUB_APP_NAME=""
NEXT_PUBLIC_SENTRY_DSN=""
NEXT_PUBLIC_ENABLE_OAUTH=0
NEXT_PUBLIC_ENABLE_SENTRY=0
NEXT_PUBLIC_ENABLE_SESSION_RECORDER=0
NEXT_PUBLIC_TRACK_EVENTS=0
NEXT_PUBLIC_SLACK_CLIENT_ID=""
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=""
NEXT_PUBLIC_DEPLOY_URL=""
NEXT_PUBLIC_DEPLOY_WITH_NGINX=1
DEBUG=0
SENTRY_DSN=""
PGUSER="plane"
PGPASSWORD="plane"
POSTGRES_USER="plane"
POSTGRES_PASSWORD="plane"
PGHOST="plane-db"
PGDATABASE="plane"
DATABASE_URL=postgresql://plane:plane@plane-db/plane
REDIS_HOST="plane-redis"
REDIS_PORT="6379"
REDIS_URL="redis://plane-redis:6379/"
EMAIL_HOST=""
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=""
EMAIL_PORT=587
EMAIL_FROM="Team Plane <team@mailer.plane.so>"
EMAIL_USE_TLS="1"
EMAIL_USE_SSL="0"
AWS_REGION=""
AWS_ACCESS_KEY_ID="${MINIO_ROOT_USER}"
AWS_SECRET_ACCESS_KEY="${MINIO_ROOT_PASSWORD}"
AWS_S3_ENDPOINT_URL="http://plane-minio:9000"
AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880
GITHUB_CLIENT_SECRET="" # For fetching release notes
USE_MINIO=1
NGINX_PORT=80
DEFAULT_EMAIL="captain@plane.so"
DEFAULT_PASSWORD="password123"
ENABLE_SIGNUP="1"

6
.gitignore vendored
View File

@ -1,3 +1,7 @@
pg_data
redis_data
minio_data
node_modules
.next
@ -31,6 +35,7 @@ yarn-error.log*
.pnpm-debug.log*
# Local env files
.env
.env.local
.env.development.local
.env.test.local
@ -48,6 +53,7 @@ venv
*.pyc
staticfiles
mediafiles
.env
.DS_Store
node_modules/

View File

@ -1,129 +1,105 @@
FROM node:18-alpine AS builder
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
ENV NEXT_PUBLIC_API_BASE_URL=http://NEXT_PUBLIC_API_BASE_URL_PLACEHOLDER
FROM git.orionkindel.com/tpl/asdf:bookworm AS system
RUN yarn global add turbo
RUN apk add tree
COPY . .
ARG S6_OVERLAY_VERSION=3.1.6.2
RUN turbo prune --scope=app --scope=plane-deploy --docker
CMD tree -I node_modules/
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
# Add lockfile and package.json's of isolated subworkspace
FROM node:18-alpine AS installer
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
RUN apk add --no-cache libc6-compat
WORKDIR /app
ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
# 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
RUN apt-get update
RUN apt-get install -y \
build-essential \
zlib1g-dev \
libncurses5-dev \
libgdbm-dev \
libnss3-dev \
libssl-dev \
libreadline-dev \
libffi-dev \
libsqlite3-dev \
wget \
libbz2-dev \
uuid-dev \
nginx \
procps
# # Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
COPY replace-env-vars.sh /usr/local/bin/
USER root
RUN chmod +x /usr/local/bin/replace-env-vars.sh
RUN asdf plugin add nodejs \
&& asdf plugin add python \
&& asdf plugin add postgres
RUN yarn turbo run build
RUN --mount=type=cache,target=/.asdf-build \
export ASDF_DOWNLOAD_PATH=/.asdf-build \
&& export TMPDIR=/.asdf-build \
&& export POSTGRES_SKIP_INITDB=y \
&& asdf install nodejs 20.9.0 \
&& asdf install python 3.11.1 \
&& asdf install postgres 15.3
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
RUN asdf global nodejs 20.9.0 \
&& asdf global postgres 15.3 \
&& asdf global python 3.11.1
RUN /usr/local/bin/replace-env-vars.sh http://NEXT_PUBLIC_WEBAPP_URL_PLACEHOLDER ${NEXT_PUBLIC_API_BASE_URL}
RUN useradd -m postgres && passwd -d postgres
FROM python:3.11.1-alpine3.17 AS backend
ADD https://dl.min.io/server/minio/release/linux-amd64/minio /usr/bin
RUN chmod +x /usr/bin/minio
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
RUN set -eo pipefail; \
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg; \
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb bookworm main" | tee /etc/apt/sources.list.d/redis.list; \
apt-get update; \
apt-get install -y redis
WORKDIR /code
FROM system AS build
RUN apk --no-cache add \
"libpq~=15" \
"libxslt~=1.1" \
"nodejs-current~=19" \
"xmlsec~=1.2" \
"nginx" \
"nodejs" \
"npm" \
"supervisor"
RUN asdf reshim
RUN npm i -g yarn
RUN --mount=type=cache,target=/.yarn-cache \
yarn config set cache-folder /.yarn-cache
COPY apiserver/requirements.txt ./
COPY apiserver/requirements ./requirements
RUN apk add --no-cache libffi-dev
RUN apk add --no-cache --virtual .build-deps \
"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
COPY package.json turbo.json yarn.lock app.json ./
COPY packages packages
COPY web web
COPY space space
COPY apiserver apiserver
RUN --mount=type=cache,target=/.yarn-cache \
--mount=type=cache,target=/web/.next \
--mount=type=cache,target=/space/.next \
yarn install && \
yarn build && \
cp -R /web/.next /web/_next && \
cp -R /space/.next /space/_next
# Add in Django deps and generate Django's static files
COPY apiserver/manage.py manage.py
COPY apiserver/plane plane/
COPY apiserver/templates templates/
RUN mv /web/_next /web/.next && \
mv /space/_next /space/.next && \
cp -R /web/.next/standalone/web/* /web/ && \
cp -R /space/.next/standalone/space/* /space/
RUN apk --no-cache add "bash~=5.2"
COPY apiserver/bin ./bin/
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
RUN chmod +x ./bin/takeoff ./bin/worker
RUN chmod -R 777 /code
RUN --mount=type=cache,target=/root/.cache/pip \
cd /apiserver \
&& pip install -r requirements.txt --compile
# Expose container port and run entry point script
FROM build AS s6
WORKDIR /app
COPY docker/etc/ /etc/
# Don't run production as root
RUN addgroup --system --gid 1001 plane
RUN adduser --system --uid 1001 captain
RUN chmod -R 777 /root \
&& chmod -R 777 /root/.asdf \
&& chmod -x /root/.asdf/lib/commands/* \
&& chmod -R 777 /apiserver \
&& chmod -R 777 /web \
&& chmod -R 777 /space \
&& ln $(asdf which postgres) /usr/bin/postgres \
&& ln $(asdf which initdb) /usr/bin/initdb \
&& ln $(asdf which node) /usr/bin/node \
&& ln $(asdf which npm) /usr/bin/npm \
&& ln $(asdf which python) /usr/bin/python
COPY --from=installer /app/apps/app/next.config.js .
COPY --from=installer /app/apps/app/package.json .
COPY --from=installer /app/apps/space/next.config.js .
COPY --from=installer /app/apps/space/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
COPY --from=installer --chown=captain:plane /app/apps/space/.next/standalone ./
COPY --from=installer --chown=captain:plane /app/apps/space/.next ./apps/space/.next
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
ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL \
BUILT_NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
USER root
COPY replace-env-vars.sh /usr/local/bin/
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"]
ENV S6_KEEP_ENV=1
ENTRYPOINT ["/init"]

View File

@ -1,55 +0,0 @@
NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS=
NEXT_PUBLIC_GOOGLE_CLIENTID=""
NEXT_PUBLIC_GITHUB_ID=""
NEXT_PUBLIC_GITHUB_APP_NAME=""
NEXT_PUBLIC_SENTRY_DSN=""
NEXT_PUBLIC_ENABLE_OAUTH=0
NEXT_PUBLIC_ENABLE_SENTRY=0
NEXT_PUBLIC_ENABLE_SESSION_RECORDER=0
NEXT_PUBLIC_TRACK_EVENTS=0
NEXT_PUBLIC_SLACK_CLIENT_ID=""
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=""
NEXT_PUBLIC_DEPLOY_URL=""
NEXT_PUBLIC_DEPLOY_WITH_NGINX=1
DEBUG=0
SENTRY_DSN=""
PGUSER="plane"
PGPASSWORD="plane"
POSTGRES_USER="plane"
POSTGRES_PASSWORD="plane"
PGHOST="plane-db"
PGDATABASE="plane"
DATABASE_URL=postgresql://plane:plane@plane-db/plane
REDIS_HOST="plane-redis"
REDIS_PORT="6379"
REDIS_URL="redis://plane-redis:6379/"
EMAIL_HOST=""
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=""
EMAIL_PORT=587
EMAIL_FROM="Team Plane <team@mailer.plane.so>"
EMAIL_USE_TLS="1"
EMAIL_USE_SSL="0"
AWS_REGION=""
AWS_ACCESS_KEY_ID="${MINIO_ROOT_USER}"
AWS_SECRET_ACCESS_KEY="${MINIO_ROOT_PASSWORD}"
AWS_S3_ENDPOINT_URL="http://plane-minio:9000"
AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880
GITHUB_CLIENT_SECRET="" # For fetching release notes
USE_MINIO=1
NGINX_PORT=80
DEFAULT_EMAIL="captain@plane.so"
DEFAULT_PASSWORD="password123"
ENABLE_SIGNUP="1"

View File

@ -0,0 +1,36 @@
events {
}
http {
sendfile on;
server {
listen 80;
root /www/data/;
access_log /var/log/nginx/access.log;
client_max_body_size 5242880;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Permissions-Policy "interest-cohort=()" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location / {
proxy_pass http://localhost:3000/;
}
location /api/ {
proxy_pass http://localhost:8000/api/;
}
location /spaces/ {
rewrite ^/spaces/?$ /spaces/login break;
proxy_pass http://localhost:3001/spaces/;
}
location /uploads/ {
proxy_pass http://localhost:9000/uploads/;
}
}
}

2296
docker/etc/redis/redis.conf Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#!/bin/bash
/bin/bash -lc 'cd /apiserver && /apiserver/bin/beat'

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,2 @@
#!/bin/bash
/bin/bash -lc 'cd /apiserver && /apiserver/bin/worker'

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,2 @@
#!/bin/bash
/bin/bash -lc 'cd /apiserver && /apiserver/bin/takeoff'

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,2 @@
#!/bin/bash
/run/s6/basedir/bin/halt

View File

@ -0,0 +1,26 @@
#!/bin/bash
script=$(mktemp)
chmod 777 "$script"
chmod -R 750 /pg_data
chown -R postgres:postgres /pg_data
cat << "EOSH" > "$script"
pgdir=/root/.asdf/installs/postgres/15.3
export POSTGRES_USER=plane
export POSTGRES_PASSWORD=plane
export POSTGRES_DB=plane
export PGDATA=/pg_data
export ROOT_DB_URL=postgresql://plane:plane@localhost:5432/postgres
export TZ=GMT
pwfile=$(mktemp)
echo -n $POSTGRES_PASSWORD > $pwfile
$pgdir/bin/initdb -U $POSTGRES_USER --pwfile=$pwfile --no-locale -L $pgdir/share/ || true
$pgdir/bin/postgres -c 'max_connections=1000'
EOSH
su postgres -c "/bin/bash $script"

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,2 @@
#!/command/execlineb -P
/usr/bin/minio server /minio_data --console-address ":9090"

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,2 @@
#!/command/execlineb -P
nginx -g "daemon off;"

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,2 @@
#!/command/execlineb -P
/usr/bin/redis-server /etc/redis/redis.conf

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1,4 @@
#!/bin/bash
HOSTNAME=127.0.0.1 \
PORT=3001 \
node /space/server.js space

View File

@ -0,0 +1 @@
longrun

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,5 @@
#!/bin/bash
NEXT_PUBLIC_DEPLOY_URL="http://localhost/spaces" \
HOSTNAME=127.0.0.1 \
PORT=3000 \
node /web/server.js web

View File

@ -0,0 +1 @@
longrun

View File

@ -1,55 +0,0 @@
NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS=
NEXT_PUBLIC_GOOGLE_CLIENTID=""
NEXT_PUBLIC_GITHUB_ID=""
NEXT_PUBLIC_GITHUB_APP_NAME=""
NEXT_PUBLIC_SENTRY_DSN=""
NEXT_PUBLIC_ENABLE_OAUTH=0
NEXT_PUBLIC_ENABLE_SENTRY=0
NEXT_PUBLIC_ENABLE_SESSION_RECORDER=0
NEXT_PUBLIC_TRACK_EVENTS=0
NEXT_PUBLIC_SLACK_CLIENT_ID=""
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=""
NEXT_PUBLIC_DEPLOY_URL=""
NEXT_PUBLIC_DEPLOY_WITH_NGINX=1
DEBUG=0
SENTRY_DSN=""
PGUSER="plane"
PGPASSWORD="plane"
POSTGRES_USER="plane"
POSTGRES_PASSWORD="plane"
PGHOST="plane-db"
PGDATABASE="plane"
DATABASE_URL=postgresql://plane:plane@plane-db/plane
REDIS_HOST="plane-redis"
REDIS_PORT="6379"
REDIS_URL="redis://plane-redis:6379/"
EMAIL_HOST=""
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=""
EMAIL_PORT=587
EMAIL_FROM="Team Plane <team@mailer.plane.so>"
EMAIL_USE_TLS="1"
EMAIL_USE_SSL="0"
AWS_REGION=""
AWS_ACCESS_KEY_ID="${MINIO_ROOT_USER}"
AWS_SECRET_ACCESS_KEY="${MINIO_ROOT_PASSWORD}"
AWS_S3_ENDPOINT_URL="http://plane-minio:9000"
AWS_S3_BUCKET_NAME="uploads"
FILE_SIZE_LIMIT=5242880
GITHUB_CLIENT_SECRET="" # For fetching release notes
USE_MINIO=1
NGINX_PORT=80
DEFAULT_EMAIL="captain@plane.so"
DEFAULT_PASSWORD="password123"
ENABLE_SIGNUP="1"