wip: Arch, devcontainer + dist, supervisord
Co-Authored-By: jonathan-irvin <jonathan-irvin@users.noreply.github.com>
This commit is contained in:
parent
b233abaa11
commit
260b281cb4
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "Postiz Dev Container",
|
||||
"image": "localhost/postiz-devcontainer",
|
||||
"features": {},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {},
|
||||
"extensions": []
|
||||
}
|
||||
},
|
||||
"forwardPorts": ["4200:4200", "3000:3000"],
|
||||
"mounts": ["source=/apps,destination=/apps/dist/,type=bind,consistency=cached"]
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# We want the docker builds to be clean, and as fast as possible. Don't send
|
||||
# any half-built stuff in the build context as a pre-caution (also saves copying
|
||||
# 180k files in node_modules that isn't used!).
|
||||
node_modules
|
||||
dist
|
||||
.nx
|
||||
77
Dockerfile
77
Dockerfile
|
|
@ -1,43 +1,52 @@
|
|||
# Foundation image
|
||||
FROM registry.fedoraproject.org/fedora-minimal:40 AS foundation
|
||||
# Base image
|
||||
FROM docker.io/node:20.17-alpine3.19 AS base
|
||||
|
||||
RUN microdnf install --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 -y \
|
||||
npm \
|
||||
node \
|
||||
&& microdnf clean all
|
||||
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Builder image
|
||||
FROM foundation AS builder
|
||||
RUN apk add --no-cache \
|
||||
bash=5.2.21-r0 \
|
||||
supervisor=4.2.5-r4
|
||||
|
||||
RUN mkdir /src
|
||||
|
||||
COPY . /src
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN npx nx reset
|
||||
RUN npm run build
|
||||
|
||||
# Output image
|
||||
FROM foundation AS dist
|
||||
|
||||
LABEL org.opencontainers.image.source=https://github.com/gitroomhq/postiz-app
|
||||
LABEL org.opencontainers.image.title="Postiz App"
|
||||
|
||||
RUN mkdir -p /config /app
|
||||
|
||||
VOLUME /config
|
||||
|
||||
COPY --from=builder /src/dist /app/dist/
|
||||
COPY --from=builder /src/package.json /app/
|
||||
COPY --from=builder /src/nx.json /app/
|
||||
|
||||
COPY .env.example /config/.env
|
||||
COPY var/docker-entrypoint.sh /app/entrypoint.sh
|
||||
WORKDIR /app
|
||||
|
||||
EXPOSE 4200
|
||||
EXPOSE 3000
|
||||
|
||||
WORKDIR /app
|
||||
RUN mkdir -p /config
|
||||
|
||||
COPY .env.example /config/.env
|
||||
|
||||
VOLUME /config
|
||||
|
||||
LABEL org.opencontainers.image.source=https://github.com/gitroomhq/postiz-app
|
||||
|
||||
# Builder image
|
||||
FROM base AS devcontainer
|
||||
|
||||
COPY nx.json tsconfig.base.json package.json package-lock.json /app/
|
||||
COPY apps /app/apps/
|
||||
COPY libraries /app/libraries/
|
||||
|
||||
RUN npm ci --no-fund && npm run build
|
||||
|
||||
COPY var/docker/entrypoint.sh /app/entrypoint.sh
|
||||
COPY var/docker/supervisord/* /app/supervisord_configs/
|
||||
|
||||
LABEL org.opencontainers.image.title="Postiz App (DevContainer)"
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
# Output image
|
||||
FROM base AS dist
|
||||
|
||||
COPY --from=devcontainer /app/node_modules/ /app/node_modules/
|
||||
COPY --from=devcontainer /app/dist/ /app/dist/
|
||||
|
||||
COPY package.json nx.json /app/
|
||||
COPY var/docker/entrypoint.sh /app/entrypoint.sh
|
||||
|
||||
## Labels at the bottom, because CI will eventially add dates, commit hashes, etc.
|
||||
LABEL org.opencontainers.image.title="Postiz App (Production)"
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
"prisma-generate": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma generate",
|
||||
"prisma-db-push": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push",
|
||||
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push --force-reset && npx prisma db push",
|
||||
"docker-build": "docker rmi localhost/postiz || true && docker build -t localhost/postiz . ",
|
||||
"docker-build": "docker rmi localhost/postiz || true && docker build --target dist -t localhost/postiz -f Dockerfile . && docker build --target devcontainer -t localhost/postiz-devcontainer -f Dockerfile .",
|
||||
"docker-create": "docker kill postiz || true && docker rm postiz || true && docker create --name postiz -p 3000:3000 -p 4200:4200 localhost/postiz",
|
||||
"postinstall": "npm run prisma-generate"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ "$SKIP_CONFIG_CHECK" -ne "true" ]]; then
|
||||
if [ ! -f /config/.env ]; then
|
||||
echo "ERROR: No .env file found in /config/.env"
|
||||
fi
|
||||
|
||||
ln -s /config/env /app/.env
|
||||
fi
|
||||
|
||||
if [[ "$POSTIZ_APPS" -eq "" ]]; then
|
||||
echo "POSTIZ_APPS is not set, starting everything!"
|
||||
POSTIZ_APPS="frontend workers cron"
|
||||
fi
|
||||
|
||||
mkdir -p /etc/supervisor.d/
|
||||
|
||||
cp /app/supervisord_configs/base.conf /etc/supervisor.d/
|
||||
|
||||
if [[ "$POSTIZ_APPS" == *"frontend"* ]]; then
|
||||
cp /app/supervisord_configs/frontend.conf /etc/supervisor.d/
|
||||
fi
|
||||
|
||||
if [[ $POSTIZ_APPS == *"workers"* ]]; then
|
||||
cp /app/supervisord_configs/workers.conf /etc/supervisor.d/
|
||||
fi
|
||||
|
||||
if [[ $POSTIZ_APPS == *"cron"* ]]; then
|
||||
cp /app/supervisord_configs/cron.conf /etc/supervisor.d/
|
||||
fi
|
||||
|
||||
if [[ $POSTIZ_APPS == *"backend"* ]]; then
|
||||
cp /app/supervisord_configs/backend.conf /etc/supervisor.d/
|
||||
fi
|
||||
|
||||
/usr/bin/supervisord
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[program:backend]
|
||||
directory=/app
|
||||
command=npm run start:prod
|
||||
autostart=true
|
||||
autorestart=false
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/dev/null
|
||||
logfile_maxbytes=0
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[program:cron]
|
||||
directory=/app
|
||||
command=npm run start:prod:cron
|
||||
autostart=true
|
||||
autorestart=false
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[program:frontend]
|
||||
directory=/app
|
||||
command=npm run start:prod:frontend
|
||||
autostart=true
|
||||
autorestart=false
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[program:workers]
|
||||
directory=/app
|
||||
command=npm run start:prod:workers
|
||||
autostart=true
|
||||
autorestart=false
|
||||
Loading…
Reference in New Issue