feat: monoimage

This commit is contained in:
orion 2023-12-11 12:23:00 -06:00
parent f3d05fda62
commit 585d9a1d1b
Signed by: orion
GPG Key ID: 6D4165AE4C928719
42 changed files with 2508 additions and 0 deletions

110
Dockerfile Normal file
View File

@ -0,0 +1,110 @@
FROM git.orionkindel.com/tpl/asdf:bookworm AS system
ARG S6_OVERLAY_VERSION=3.1.6.2
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 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 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
RUN asdf plugin add nodejs \
&& asdf plugin add python \
&& asdf plugin add postgres
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
RUN asdf global nodejs 20.9.0 \
&& asdf global postgres 15.3 \
&& asdf global python 3.11.1
RUN useradd -m postgres && passwd -d postgres
ADD https://dl.min.io/server/minio/release/linux-amd64/minio /usr/bin
RUN chmod +x /usr/bin/minio
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
FROM system AS next_prebuild
RUN npm i -g yarn
RUN --mount=type=cache,target=/.yarn-cache \
yarn config set cache-folder /.yarn-cache
COPY package.json turbo.json yarn.lock app.json ./
COPY packages packages
COPY web web
COPY space space
RUN --mount=type=cache,target=/.yarn-cache \
yarn install
FROM next_prebuild AS next_build
RUN --mount=type=cache,target=/.yarn-cache \
--mount=type=cache,target=/web/.next \
--mount=type=cache,target=/space/.next \
yarn build && \
cp -R /web/.next /web/_next && \
cp -R /space/.next /space/_next
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/
FROM next_build AS api_build
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
COPY apiserver apiserver
RUN --mount=type=cache,target=/root/.cache/pip \
cd /apiserver \
&& pip install -r requirements.txt --compile
FROM api_build AS s6
COPY docker/etc/ /etc/
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
ENV S6_KEEP_ENV=1
ENTRYPOINT ["/init"]

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