diff --git a/Dockerfile b/Dockerfile index 10cce9e58..e3d4e4c93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,77 @@ -FROM git.orionkindel.com/tpl/asdf:bookworm-full AS base +FROM debian:bookworm -RUN apt-get update && apt-get install -y wget nginx procps lsb-release tmux -RUN wget https://dl.min.io/server/minio/release/linux-amd64/minio -O /usr/bin/minio && chmod +x /usr/bin/minio +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && apt-get install -y wget nginx procps lsb-release tmux python3 python3-pip nodejs npm curl + +RUN wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20240629012047.0.0_amd64.deb -O minio.deb +RUN apt-get install -y -f ./minio.deb + +RUN wget https://go.dev/dl/go1.22.4.linux-amd64.tar.gz +RUN tar -C /usr/local -xzf go1.22.4.linux-amd64.tar.gz + +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/root/go/bin RUN go install github.com/DarthSim/overmind/v2@latest -RUN asdf global python 3.12.3 && asdf plugin remove postgres && pip install setuptools + RUN npm i -g yarn && yarn set version 1.22.19 -RUN sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \ +SHELL ["/bin/bash", "-c"] + +RUN --mount=type=cache,target=/root/.cache/yarn \ + --mount=type=cache,target=/var/cache/apt \ + sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \ && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ && apt-get update \ - && apt-get -y install postgresql + && apt-get -y install postgresql libpq-dev -RUN set -eo pipefail; \ +RUN --mount=type=cache,target=/root/.cache/yarn \ + --mount=type=cache,target=/var/cache/apt \ + 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 base AS run - -COPY --from=git.orionkindel.com/thunderstrike/plane-base:latest /app /app -COPY --from=git.orionkindel.com/thunderstrike/plane-base:latest /etc /etc -COPY --from=git.orionkindel.com/thunderstrike/plane-base:latest /root/.asdf/installs/python /root/.asdf/installs/python +RUN apt-get install --reinstall python3 python3-pip +RUN mkdir /app WORKDIR /app +COPY package.json turbo.json yarn.lock app.json . +COPY packages packages +COPY web web +COPY space space + +RUN --mount=type=cache,target=/root/.cache/yarn \ + yarn install --frozen-lockfile \ + && yarn build \ + && rm -rf node_modules + +RUN mkdir -p web/.next/standalone/web/.next \ + && mv web/public web/.next/standalone/web/public \ + && mv web/.next/static web/.next/standalone/web/.next/static \ + && mkdir -p space/.next/standalone/_next \ + && mv space/public space/.next/standalone/space/public \ + && mv space/.next/static space/.next/standalone/space/.next/static + +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 --break-system-packages -r requirements.txt --compile \ + && pip install --break-system-packages -r requirements/local.txt --compile + +COPY docker/etc/ /etc/ + RUN chmod -R 755 /root \ - && chmod -R 755 /root/.asdf \ && chmod -R 755 apiserver \ && chmod -R 755 web \ && chmod -R 755 space \ - && chmod -x /root/.asdf/lib/commands/* \ - && chmod +x /etc/db-run.sh \ - && ln $(asdf which node) /usr/bin/node \ - && ln $(asdf which npm) /usr/bin/npm \ - && ln $(asdf which python) /usr/bin/python + && chmod +x /etc/db-run.sh -ENTRYPOINT ["bash", "-lc", "/etc/entrypoint.sh"] +RUN apt-get install -y python-is-python3 python3-setuptools + +ENTRYPOINT ["bash", "/etc/entrypoint.sh"] diff --git a/Dockerfile.base b/Dockerfile.base deleted file mode 100644 index 72afd3dc1..000000000 --- a/Dockerfile.base +++ /dev/null @@ -1,58 +0,0 @@ -FROM git.orionkindel.com/tpl/asdf:bookworm-full AS system - -RUN apt-get update && apt-get install -y wget nginx procps lsb-release tmux -RUN wget https://dl.min.io/server/minio/release/linux-amd64/minio -O /usr/bin/minio && chmod +x /usr/bin/minio -RUN go install github.com/DarthSim/overmind/v2@latest -RUN asdf global python 3.12.3 && asdf plugin remove postgres && pip install setuptools -RUN npm i -g yarn && yarn set version 1.22.19 - -RUN sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \ - && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ - && apt-get update \ - && apt-get -y install postgresql - -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_build - -RUN mkdir /app -WORKDIR /app - -COPY package.json turbo.json yarn.lock app.json . -COPY packages packages -COPY web web -COPY space space - -RUN --mount=type=cache,target=/root/.cache/yarn \ - yarn install --frozen-lockfile \ - && yarn build \ - && rm -rf node_modules - -RUN mkdir -p web/.next/standalone/web/.next \ - && mv web/public web/.next/standalone/web/public \ - && mv web/.next/static web/.next/standalone/web/.next/static \ - && mkdir -p space/.next/standalone/_next \ - && mv space/public space/.next/standalone/space/public \ - && mv space/.next/static space/.next/standalone/space/.next/static - -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 \ - && pip install -r requirements/local.txt --compile - -FROM api_build AS run - -COPY docker/etc/ /etc/ - -ENTRYPOINT ["bash", "-l"] diff --git a/apiserver/bin/docker-entrypoint-api.sh b/apiserver/bin/docker-entrypoint-api.sh index 5a1da1570..217e4dc32 100755 --- a/apiserver/bin/docker-entrypoint-api.sh +++ b/apiserver/bin/docker-entrypoint-api.sh @@ -32,4 +32,4 @@ python manage.py create_bucket # Clear Cache before starting to remove stale values python manage.py clear_cache -exec gunicorn -w "$GUNICORN_WORKERS" -k uvicorn.workers.UvicornWorker plane.asgi:application --bind 0.0.0.0:"${PORT:-8000}" --max-requests 1200 --max-requests-jitter 1000 --access-logfile - +exec gunicorn --log-level debug --timeout 30 -w "$GUNICORN_WORKERS" -k uvicorn.workers.UvicornWorker plane.asgi:application --bind 0.0.0.0:"${PORT:-8000}" --max-requests 1200 --max-requests-jitter 1000 --access-logfile - diff --git a/docker/etc/Procfile b/docker/etc/Procfile index 111aef02b..15676f3f6 100644 --- a/docker/etc/Procfile +++ b/docker/etc/Procfile @@ -1,9 +1,9 @@ migrator: sh -c "cd /app/apiserver && python manage.py wait_for_db --settings=plane.settings.local && python manage.py migrate --settings=plane.settings.local" -api: /bin/bash -lc 'cd /app/apiserver && ./bin/takeoff' -api-beatworker: /bin/bash -lc 'cd /app/apiserver && ./bin/beat' -api-worker: /bin/bash -lc 'cd /app/apiserver && ./bin/worker' +api: cd /app/apiserver/ && bin/takeoff +api-beatworker: cd /app/apiserver/ && bin/beat +api-worker: cd /app/apiserver/ && bin/worker db: /etc/db-run.sh -minio: /usr/bin/minio server /ext/minio_data --console-address ":9090" +minio: minio server /ext/minio_data --console-address ":9090" nginx: nginx -g "daemon off;" redis: /usr/bin/redis-server /etc/redis/redis.conf spaces: cd /app/space/.next/standalone/space && HOSTNAME=127.0.0.1 PORT=3001 node server.js space diff --git a/docker/etc/entrypoint.sh b/docker/etc/entrypoint.sh index 3f3fbec21..3a3b476bd 100755 --- a/docker/etc/entrypoint.sh +++ b/docker/etc/entrypoint.sh @@ -1,7 +1,7 @@ #! /bin/bash mkdir -p /ext/redis_data /ext/minio_data /ext/pg_data -asdf reshim +export PATH=$PATH:/usr/bin:/usr/local/bin:/root/go/bin:/bin:/usr/sbin:/usr/local/sbin OVERMIND_CAN_DIE=migrator \ OVERMIND_AUTO_RESTART=api,web,spaces,api-worker,api-beatworker \ diff --git a/fly.toml b/fly.toml index 27dd1f46f..edfcc6074 100644 --- a/fly.toml +++ b/fly.toml @@ -1,18 +1,18 @@ -# fly.toml app configuration file generated for lopiq-plane on 2024-04-13T19:01:18-05:00 +# fly.toml app configuration file generated for orion-plane on 2024-06-29T13:11:37-05:00 # # See https://fly.io/docs/reference/configuration/ for information about how to use this file. # -app = 'lopiq-plane' +app = 'orion-plane' primary_region = 'ord' [build] - image = 'git.orionkindel.com/thunderstrike/plane:stable-46b18dca279a49eeba91e4d99021fb95' +dockerfile = "Dockerfile" [env] AWS_S3_BUCKET_NAME = 'uploads' AWS_S3_ENDPOINT_URL = 'http://localhost:9000' - CORS_ALLOWED_ORIGINS = 'http://plane.lopiq.com' + CORS_ALLOWED_ORIGINS = 'http://plane.scour.cc' DATABASE_URL = 'postgresql://plane:plane@localhost:5432/plane' DEBUG = '0' ENABLE_EMAIL_PASSWORD = '0' @@ -37,7 +37,7 @@ primary_region = 'ord' REDIS_URL = 'redis://localhost:6379/' SENTRY_ENVIRONMENT = 'development' USE_MINIO = '1' - WEB_URL = 'http://plane.lopiq.com' + WEB_URL = 'http://plane.scour.cc' [[mounts]] source = 'volume' @@ -48,10 +48,9 @@ primary_region = 'ord' force_https = true auto_stop_machines = true auto_start_machines = true - min_machines_running = 0 + min_machines_running = 1 processes = ['app'] [[vm]] + size = 'shared-cpu-2x' memory = '1gb' - cpu_kind = 'shared' - cpus = 1