Improve deployment process and add login redirect logic
Deployment improvements: - Add template env files (.envs.example/) for documentation - Create init-production.sh for one-time server setup - Create build-activepieces.sh for building/deploying AP image - Update deploy.sh with --deploy-ap flag - Make custom-pieces-metadata.sql idempotent - Update DEPLOYMENT.md with comprehensive instructions Frontend: - Redirect logged-in business owners from root domain to tenant dashboard - Redirect logged-in users from /login to /dashboard on their tenant - Log out customers on wrong subdomain instead of redirecting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
FROM node:20.19-bullseye-slim AS base
|
||||
|
||||
# Set environment variables early for better layer caching
|
||||
# Memory optimizations for low-RAM servers (2GB):
|
||||
# - Limit Node.js heap to 1536MB to leave room for system
|
||||
# - Disable NX daemon and cloud to reduce overhead
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US:en \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
NX_DAEMON=false \
|
||||
NX_NO_CLOUD=true
|
||||
NX_NO_CLOUD=true \
|
||||
NODE_OPTIONS="--max-old-space-size=1536"
|
||||
|
||||
# Install all system dependencies in a single layer with cache mounts
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
@@ -63,7 +67,7 @@ RUN --mount=type=cache,target=/root/.bun/install/cache \
|
||||
COPY . .
|
||||
|
||||
# Build all projects including custom pieces
|
||||
RUN npx nx run-many --target=build --projects=react-ui,server-api,pieces-smoothschedule,pieces-python-code,pieces-ruby-code --configuration production --parallel=2 --skip-nx-cache --verbose
|
||||
RUN npx nx run-many --target=build --projects=react-ui,server-api,pieces-smoothschedule,pieces-python-code,pieces-ruby-code,pieces-interfaces --configuration production --parallel=2 --skip-nx-cache
|
||||
|
||||
# Install production dependencies only for the backend API
|
||||
RUN --mount=type=cache,target=/root/.bun/install/cache \
|
||||
@@ -77,6 +81,8 @@ RUN --mount=type=cache,target=/root/.bun/install/cache \
|
||||
cd ../python-code && \
|
||||
bun install --production && \
|
||||
cd ../ruby-code && \
|
||||
bun install --production && \
|
||||
cd ../interfaces && \
|
||||
bun install --production
|
||||
|
||||
### STAGE 2: Run ###
|
||||
@@ -84,24 +90,30 @@ FROM base AS run
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install Nginx and gettext in a single layer with cache mount
|
||||
# Install Nginx, gettext, and PostgreSQL client in a single layer with cache mount
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends nginx gettext
|
||||
apt-get install -y --no-install-recommends nginx gettext postgresql-client
|
||||
|
||||
# Copy static configuration files first (better layer caching)
|
||||
COPY nginx.react.conf /etc/nginx/nginx.conf
|
||||
COPY --from=build /usr/src/app/packages/server/api/src/assets/default.cf /usr/local/etc/isolate
|
||||
COPY docker-entrypoint.sh .
|
||||
COPY custom-pieces-metadata.sql .
|
||||
COPY publish-pieces.sh .
|
||||
|
||||
# Create all necessary directories in one layer
|
||||
# Also create symlink for AP_DEV_PIECES to find pieces in dist folder
|
||||
# Structure: /packages/pieces/community -> /dist/packages/pieces/community
|
||||
RUN mkdir -p \
|
||||
/usr/src/app/dist/packages/server \
|
||||
/usr/src/app/dist/packages/engine \
|
||||
/usr/src/app/dist/packages/shared \
|
||||
/usr/src/app/dist/packages/pieces && \
|
||||
chmod +x docker-entrypoint.sh
|
||||
/usr/src/app/dist/packages/pieces \
|
||||
/usr/src/app/packages/pieces && \
|
||||
ln -sf /usr/src/app/dist/packages/pieces/community /usr/src/app/packages/pieces/community && \
|
||||
chmod +x docker-entrypoint.sh publish-pieces.sh
|
||||
|
||||
# Copy built artifacts from build stage
|
||||
COPY --from=build /usr/src/app/LICENSE .
|
||||
|
||||
Reference in New Issue
Block a user