-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Arch, devcontainer + dist, supervisord
- Loading branch information
Showing
10 changed files
with
119 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
WORKDIR /app | ||
|
||
COPY . /src | ||
EXPOSE 4200 | ||
EXPOSE 3000 | ||
|
||
WORKDIR /src | ||
RUN mkdir -p /config | ||
|
||
RUN npx nx reset | ||
RUN npm run build | ||
COPY .env.example /config/.env | ||
|
||
# Output image | ||
FROM foundation AS dist | ||
VOLUME /config | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/gitroomhq/postiz-app | ||
LABEL org.opencontainers.image.title="Postiz App" | ||
|
||
RUN mkdir -p /config /app | ||
# Builder image | ||
FROM base AS devcontainer | ||
|
||
VOLUME /config | ||
COPY nx.json tsconfig.base.json package.json package-lock.json /app/ | ||
COPY apps /app/apps/ | ||
COPY libraries /app/libraries/ | ||
|
||
COPY --from=builder /src/dist /app/dist/ | ||
COPY --from=builder /src/package.json /app/ | ||
COPY --from=builder /src/nx.json /app/ | ||
RUN npm ci --no-fund && npm run build | ||
|
||
COPY .env.example /config/.env | ||
COPY var/docker-entrypoint.sh /app/entrypoint.sh | ||
COPY var/docker/entrypoint.sh /app/entrypoint.sh | ||
COPY var/docker/supervisord/* /app/supervisord_configs/ | ||
|
||
EXPOSE 4200 | ||
EXPOSE 3000 | ||
LABEL org.opencontainers.image.title="Postiz App (DevContainer)" | ||
|
||
WORKDIR /app | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[program:backend] | ||
directory=/app | ||
command=npm run start:prod | ||
autostart=true | ||
autorestart=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[supervisord] | ||
nodaemon=true | ||
logfile=/dev/null | ||
logfile_maxbytes=0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[program:cron] | ||
directory=/app | ||
command=npm run start:prod:cron | ||
autostart=true | ||
autorestart=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[program:frontend] | ||
directory=/app | ||
command=npm run start:prod:frontend | ||
autostart=true | ||
autorestart=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[program:workers] | ||
directory=/app | ||
command=npm run start:prod:workers | ||
autostart=true | ||
autorestart=false |