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"]