Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup one click deployment to railway #356

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 0 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ COPY --from=devcontainer /app/libraries/ /app/libraries/

COPY package.json nx.json /app/

VOLUME /config
VOLUME /uploads

## Labels at the bottom, because CI will eventually add dates, commit hashes, etc.
LABEL org.opencontainers.image.title="Postiz App (Production)"
72 changes: 72 additions & 0 deletions Dockerfile.railway
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This Dockerfile is used for producing 3 container images.
#
# base - which is thrown away, that contains node and the basic infrastructure.
# devcontainer - which is used for development, and contains the source code and the node_modules.
# dist - which is used for production, and contains the built source code and the node_modules.

ARG NODE_VERSION="20.17"

# Base image
FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS base

## Just reduce unccessary noise in the logs.
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NEXT_TELEMETRY_DISABLED=1

RUN apk add --no-cache \
caddy \
bash=5.2.21-r0 \
supervisor=4.2.5-r4

WORKDIR /app

EXPOSE 3000
EXPOSE 4200
EXPOSE 5000

COPY var/docker/entrypoint.sh /app/entrypoint.sh
COPY var/docker/supervisord.conf /etc/supervisord.conf
COPY var/docker/supervisord /app/supervisord_available_configs/
COPY var/docker/Caddyfile /app/Caddyfile
COPY .env.example /config/postiz.env


LABEL org.opencontainers.image.source=https://github.com/gitroomhq/postiz-app

ENTRYPOINT ["/app/entrypoint.sh"]

# Builder image
FROM base AS devcontainer

RUN apk add --no-cache \
pkgconfig \
gcc \
pixman-dev \
cairo-dev \
pango-dev \
make \
build-base

COPY nx.json tsconfig.base.json package.json package-lock.json build.plugins.js /app/
COPY apps /app/apps/
COPY libraries /app/libraries/

RUN npm ci --no-fund && npx nx run-many --target=build --projects=frontend,backend,workers,cron


LABEL org.opencontainers.image.title="Postiz App (DevContainer)"

# Output image
FROM base AS dist

COPY --from=devcontainer /app/node_modules/ /app/node_modules/
COPY --from=devcontainer /app/dist/ /app/dist/

# Required for prisma
COPY --from=devcontainer /app/libraries/ /app/libraries/

COPY package.json nx.json /app/


## Labels at the bottom, because CI will eventually add dates, commit hashes, etc.
LABEL org.opencontainers.image.title="Postiz App (Production)"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
## Quick Start
To have the project up and running, please follow the [Quick Start Guide](https://docs.postiz.com/quickstart)

##
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/XlBTKC)


# License
Expand Down
7 changes: 7 additions & 0 deletions railway.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build]
builder = "DOCKERFILE"
dockerfilePath = "Dockerfile.railway"

[deploy]
restartPolicyType = "ON_FAILURE"