Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions deploy/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,33 @@ const setOrUpdateMetaTag = ($: CheerioAPI, selector: string, attribute: string,
}
};

const logger = pino({
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'SYS:standard',
},
const prettyTransport = {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'SYS:standard',
},
};

const logger = pino({
transport: process.env.NODE_ENV === 'production' ? undefined : prettyTransport,
level: process.env.LOG_LEVEL || 'info',
});

const logRequestTimer = (req: Request) => {
const start = Date.now();
const pathname = new URL(req.url).pathname;

logger.info(`Incoming request: ${pathname}`);
if (!pathname.startsWith('/health')) {
logger.info(`Incoming request: ${pathname}`);
}

return () => {
const duration = Date.now() - start;

logger.info(`Request for ${pathname} took ${duration}ms`);
if (!pathname.startsWith('/health')) {
logger.info(`Request for ${pathname} took ${duration}ms`);
}
};
};

Expand Down Expand Up @@ -76,7 +83,9 @@ const createServer = async (req: Request) => {
const reqUrl = new URL(req.url);
const hostname = req.headers.get('host');

logger.info(`Request URL: ${hostname}${reqUrl.pathname}`);
if (!reqUrl.pathname.startsWith('/health')) {
logger.info(`Request URL: ${hostname}${reqUrl.pathname}`);
}

if (reqUrl.pathname === '/') {
timer();
Expand Down
5 changes: 5 additions & 0 deletions docker/Dockerfile.ssr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Build stage - Build the React application
FROM node:20.12.0-alpine AS builder

ARG VERSION=dev
ENV NODE_ENV=production

WORKDIR /app
Expand Down Expand Up @@ -46,6 +47,10 @@ COPY docker/entrypoint-ssr.sh /docker-entrypoint.sh
# Make entrypoint executable
RUN chmod +x /docker-entrypoint.sh

# Set version as environment variable (from build arg)
ARG VERSION
ENV APP_VERSION=${VERSION}

# Expose port 80
EXPOSE 80

Expand Down
6 changes: 6 additions & 0 deletions docker/entrypoint-ssr.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/sh
set -e

# Print version banner
echo "════════════════════════════════════════════════════════════════════"
echo " AppFlowy Web v${APP_VERSION:-dev}"
echo "════════════════════════════════════════════════════════════════════"
echo ""

# Backward compatibility: Map old environment variable names to new ones
if [ -n "${AF_BASE_URL}" ] && [ -z "${APPFLOWY_BASE_URL}" ]; then
echo "⚠️ WARNING: AF_BASE_URL is deprecated. Please use APPFLOWY_BASE_URL instead."
Expand Down
6 changes: 4 additions & 2 deletions docker/supervisord-ssr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ priority=10
command=bun run /app/server.ts
autostart=true
autorestart=true
stdout_logfile=/var/log/bun.out.log
stderr_logfile=/var/log/bun.err.log
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=NODE_ENV="production"
priority=20