mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: nginx configration
This commit is contained in:
@@ -7,11 +7,14 @@ export async function POST(request: Request) {
|
|||||||
try {
|
try {
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const event = body.Event
|
const event = body.Event
|
||||||
|
console.log(body);
|
||||||
const headers = event.HTTPRequest.Header
|
const headers = event.HTTPRequest.Header
|
||||||
const uploadLength = headers["X-File-Size"]?.[0];
|
const uploadLength = headers["X-File-Size"]?.[0];
|
||||||
const uploadOffset = headers["Upload-Offset"]?.[0];
|
const uploadOffset = headers["Upload-Offset"]?.[0];
|
||||||
const status = headers["X-Status"]?.[0];
|
const status = headers["X-Status"]?.[0];
|
||||||
|
|
||||||
|
console.log(headers);
|
||||||
|
|
||||||
console.log(`Upload ID : ${event.Upload.ID} (${uploadOffset}/${uploadLength})`);
|
console.log(`Upload ID : ${event.Upload.ID} (${uploadOffset}/${uploadLength})`);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+53
-133
@@ -1,115 +1,5 @@
|
|||||||
#FROM node:22-alpine AS base
|
#FROM node:22-bullseye AS base
|
||||||
#
|
FROM --platform=$BUILDPLATFORM node:22-bullseye AS base
|
||||||
#RUN apk add --update --no-cache \
|
|
||||||
# libc6-compat \
|
|
||||||
# openssl \
|
|
||||||
# tzdata
|
|
||||||
#
|
|
||||||
#FROM base AS tusd-base
|
|
||||||
#
|
|
||||||
#RUN apk add --no-cache curl ca-certificates bash \
|
|
||||||
# && TUSD_VERSION=1.28.0 \
|
|
||||||
# && curl -L -o /usr/local/bin/tusd https://github.com/tus/tusd/releases/download/v${TUSD_VERSION}/tusd-${TUSD_VERSION}-linux-amd64 \
|
|
||||||
# && chmod +x /usr/local/bin/tusd
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#FROM base AS build-env
|
|
||||||
#
|
|
||||||
#RUN apk add --update --no-cache \
|
|
||||||
# build-base \
|
|
||||||
# g++ \
|
|
||||||
# make \
|
|
||||||
# libtool \
|
|
||||||
# autoconf \
|
|
||||||
# automake
|
|
||||||
#
|
|
||||||
#RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#FROM build-env AS deps
|
|
||||||
#
|
|
||||||
#WORKDIR /app
|
|
||||||
#
|
|
||||||
#COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
||||||
#
|
|
||||||
#RUN pnpm i --frozen-lockfile
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#FROM build-env AS dev
|
|
||||||
#
|
|
||||||
#COPY --from=tusd-base /usr/local/bin/tusd /usr/local/bin/tusd
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#WORKDIR /app
|
|
||||||
#
|
|
||||||
#COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
#COPY . .
|
|
||||||
#
|
|
||||||
#USER root
|
|
||||||
#
|
|
||||||
#RUN chmod +x /app/docker/entrypoints/app-dev-entrypoint.sh
|
|
||||||
#ENTRYPOINT ["sh","/app/docker/entrypoints/app-dev-entrypoint.sh"]
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#FROM build-env AS builder
|
|
||||||
#
|
|
||||||
#WORKDIR /app
|
|
||||||
#COPY --from=deps /app/node_modules ./node_modules
|
|
||||||
#COPY . .
|
|
||||||
#
|
|
||||||
#ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
#
|
|
||||||
#RUN pnpm run build
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#FROM base AS prod
|
|
||||||
#
|
|
||||||
#COPY --from=tusd-base /usr/local/bin/tusd /usr/local/bin/tusd
|
|
||||||
#
|
|
||||||
#WORKDIR /app
|
|
||||||
#
|
|
||||||
#ENV NODE_ENV=production
|
|
||||||
#ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
#
|
|
||||||
#RUN addgroup --system --gid 1001 nodejs
|
|
||||||
#RUN adduser --system --uid 1001 nextjs
|
|
||||||
#
|
|
||||||
#COPY --from=builder /app/public ./public
|
|
||||||
#
|
|
||||||
#RUN mkdir .next
|
|
||||||
#RUN chown nextjs:nodejs .next
|
|
||||||
#RUN mkdir -p /app/private/uploads
|
|
||||||
#RUN chown -R nextjs:nodejs /app/private
|
|
||||||
#RUN chown -R nextjs:nodejs /app/public
|
|
||||||
#
|
|
||||||
#COPY --from=builder /app/next.config.ts ./
|
|
||||||
#
|
|
||||||
#COPY --from=builder /app/portabase.config.ts ./
|
|
||||||
#COPY --from=builder /app/drizzle.config.ts ./
|
|
||||||
#COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
||||||
#COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
||||||
#COPY --chown=nextjs:nodejs src/db ./src/db
|
|
||||||
#
|
|
||||||
#USER root
|
|
||||||
#
|
|
||||||
#COPY ./docker/entrypoints/app-prod-entrypoint.sh /app/app-prod-entrypoint.sh
|
|
||||||
#RUN chmod +x /app/app-prod-entrypoint.sh
|
|
||||||
#
|
|
||||||
#EXPOSE 80
|
|
||||||
#
|
|
||||||
#ENV PORT=80
|
|
||||||
#
|
|
||||||
#ENV HOSTNAME="0.0.0.0"
|
|
||||||
#
|
|
||||||
#USER nextjs
|
|
||||||
#
|
|
||||||
#ENTRYPOINT ["sh","/app/app-prod-entrypoint.sh"]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM node:22-bullseye AS base
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
curl \
|
curl \
|
||||||
@@ -124,30 +14,55 @@ RUN apt-get update && apt-get install -y \
|
|||||||
automake \
|
automake \
|
||||||
libtool \
|
libtool \
|
||||||
git \
|
git \
|
||||||
|
nginx \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
FROM base AS tusd-base
|
#FROM base AS tusd-base
|
||||||
|
#
|
||||||
|
#ENV TUSD_VERSION=2.8.0
|
||||||
|
#
|
||||||
|
#RUN apt-get update && apt-get install -y \
|
||||||
|
# curl \
|
||||||
|
# ca-certificates \
|
||||||
|
# bash \
|
||||||
|
# tar \
|
||||||
|
# gzip \
|
||||||
|
# libssl-dev \
|
||||||
|
# && rm -rf /var/lib/apt/lists/*
|
||||||
|
#
|
||||||
|
## Download and extract tusd
|
||||||
|
#RUN curl -L -o /tmp/tusd.tar.gz \
|
||||||
|
# https://github.com/tus/tusd/releases/download/v${TUSD_VERSION}/tusd_linux_amd64.tar.gz \
|
||||||
|
# && mkdir -p /usr/local/bin \
|
||||||
|
# && tar -xzf /tmp/tusd.tar.gz -C /tmp \
|
||||||
|
# # Move the actual binary, whatever its name/folder inside tar
|
||||||
|
# && mv /tmp/*/tusd /usr/local/bin/tusd \
|
||||||
|
# && chmod +x /usr/local/bin/tusd \
|
||||||
|
# && /usr/local/bin/tusd --version
|
||||||
|
|
||||||
ENV TUSD_VERSION=2.8.0
|
# Use Debian-based Go for reliable networking/DNS during build
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:1.23-bookworm AS tusd-base
|
||||||
|
|
||||||
|
ARG TUSD_VERSION=2.8.0
|
||||||
|
|
||||||
|
# Install git
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
RUN git clone https://github.com/tus/tusd.git . \
|
||||||
|
&& git checkout v${TUSD_VERSION}
|
||||||
|
|
||||||
|
# Build statically linked binary
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} \
|
||||||
|
go build -ldflags="-s -w" -o /tusddist/tusd ./cmd/tusd
|
||||||
|
|
||||||
|
# Minimal dist stage (scratch keeps final image small)
|
||||||
|
FROM scratch AS tusd-dist
|
||||||
|
COPY --from=tusd-base /tusddist/tusd /tusd
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
curl \
|
|
||||||
ca-certificates \
|
|
||||||
bash \
|
|
||||||
tar \
|
|
||||||
gzip \
|
|
||||||
libssl-dev \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Download and extract tusd
|
|
||||||
RUN curl -L -o /tmp/tusd.tar.gz \
|
|
||||||
https://github.com/tus/tusd/releases/download/v${TUSD_VERSION}/tusd_linux_amd64.tar.gz \
|
|
||||||
&& mkdir -p /usr/local/bin \
|
|
||||||
&& tar -xzf /tmp/tusd.tar.gz -C /tmp \
|
|
||||||
# Move the actual binary, whatever its name/folder inside tar
|
|
||||||
&& mv /tmp/*/tusd /usr/local/bin/tusd \
|
|
||||||
&& chmod +x /usr/local/bin/tusd \
|
|
||||||
&& /usr/local/bin/tusd --version
|
|
||||||
|
|
||||||
FROM base AS build-env
|
FROM base AS build-env
|
||||||
|
|
||||||
@@ -201,7 +116,12 @@ COPY --from=builder --chown=1001:1001 /app/.next/static ./.next/static
|
|||||||
COPY --chown=1001:1001 src/db ./src/db
|
COPY --chown=1001:1001 src/db ./src/db
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
|
||||||
COPY --from=tusd-base /usr/local/bin/tusd /usr/local/bin/tusd
|
#COPY --from=tusd-base /usr/local/bin/tusd /usr/local/bin/tusd
|
||||||
|
COPY --from=tusd-dist /tusd /usr/local/bin/tusd
|
||||||
|
RUN chmod +x /usr/local/bin/tusd
|
||||||
|
|
||||||
|
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
|
||||||
RUN mkdir -p .next /app/private/uploads \
|
RUN mkdir -p .next /app/private/uploads \
|
||||||
&& chown -R nextjs:nodejs .next /app/private /app/public
|
&& chown -R nextjs:nodejs .next /app/private /app/public
|
||||||
@@ -211,5 +131,5 @@ COPY ./docker/entrypoints/app-prod-entrypoint.sh /app/app-prod-entrypoint.sh
|
|||||||
RUN chmod +x /app/app-prod-entrypoint.sh
|
RUN chmod +x /app/app-prod-entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
USER nextjs
|
#USER nextjs
|
||||||
ENTRYPOINT ["sh","/app/app-prod-entrypoint.sh"]
|
ENTRYPOINT ["sh","/app/app-prod-entrypoint.sh"]
|
||||||
|
|||||||
@@ -7,12 +7,21 @@ else
|
|||||||
echo "[WARN] No TZ provided, using default container timezone"
|
echo "[WARN] No TZ provided, using default container timezone"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start tusd as background process
|
mkdir -p /app/private/uploads/tmp
|
||||||
mkdir -p /app/private/uploads
|
|
||||||
echo "▶ Starting tusd server..."
|
echo "▶ Starting tusd server..."
|
||||||
tusd --dir /app/private/uploads --hooks-http http://localhost:80/api/tus/hooks --port 1080 &
|
#tusd --dir /app/private/uploads/tmp --hooks-http http://localhost:80/api/tus/hooks --port 1080 &
|
||||||
|
#tusd --upload-dir /app/private/uploads/tmp --hooks-http http://localhost:3000/api/tus/hooks --port 1080 --max-size 21474836480 &
|
||||||
|
#tusd --base-path /tus --upload-dir /app/private/uploads/tmp --hooks-http http://127.0.0.1:3000/api/tus/hooks --port 1080 --max-size 21474836480 --hooks-http-forward-headers "*" &
|
||||||
|
#tusd --upload-dir /app/private/uploads/tmp --hooks-http http://127.0.0.1:3000/api/tus/hooks --port 1080 --max-size 21474836480 --hooks-http-forward-headers "X-Generated-Id" &
|
||||||
|
#tusd --upload-dir /app/private/uploads/tmp --hooks-http http://127.0.0.1:3000/api/tus/hooks --port 1080 --max-size 21474836480 --behind-proxy true --hooks-http-forward-headers "X-Generated-Id" &
|
||||||
|
tusd --base-path /tus/files/ --upload-dir /app/private/uploads/tmp --hooks-http http://127.0.0.1:3000/api/tus/hooks --port 1080 --max-size 21474836480 &
|
||||||
|
|
||||||
node server.js
|
echo "▶ Starting Next.js server..."
|
||||||
|
PORT=3000 node server.js &
|
||||||
|
|
||||||
exec "$@"
|
echo "▶ Starting nginx..."
|
||||||
|
exec nginx -g "daemon off;"
|
||||||
|
|
||||||
|
|
||||||
|
#exec "$@"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
events {}
|
||||||
|
|
||||||
|
http {
|
||||||
|
client_max_body_size 20G;
|
||||||
|
ignore_invalid_headers off;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
# TUS uploads – zero buffering
|
||||||
|
# location /tus/ {
|
||||||
|
# proxy_pass http://127.0.0.1:1080/;
|
||||||
|
# # proxy_request_buffering off;
|
||||||
|
# # proxy_buffering off;
|
||||||
|
# # proxy_http_version 1.1;
|
||||||
|
location /tus/ {
|
||||||
|
# rewrite ^/tus/(.*)$ /$1 break;
|
||||||
|
# proxy_pass http://127.0.0.1:1080/;
|
||||||
|
# proxy_request_buffering off;
|
||||||
|
# proxy_buffering off;
|
||||||
|
# proxy_http_version 1.1;
|
||||||
|
proxy_pass http://127.0.0.1:1080/tus/;
|
||||||
|
|
||||||
|
proxy_pass_request_headers on;
|
||||||
|
|
||||||
|
# proxy_set_header Host $host;
|
||||||
|
# proxy_set_header X-Forwarded-Host $host;
|
||||||
|
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
# Disable request and response buffering
|
||||||
|
proxy_request_buffering off;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
# Add X-Forwarded-* headers
|
||||||
|
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
||||||
|
|
||||||
|
# proxy_set_header X-Forwarded-Host $host:$server_port;
|
||||||
|
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
# # proxy_set_header Connection "";
|
||||||
|
client_max_body_size 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Next.js
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:3000;
|
||||||
|
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
-12
@@ -47,18 +47,18 @@ const nextConfig: NextConfig = {
|
|||||||
},
|
},
|
||||||
proxyClientMaxBodySize: '10gb',
|
proxyClientMaxBodySize: '10gb',
|
||||||
},
|
},
|
||||||
async rewrites() {
|
// async rewrites() {
|
||||||
return [
|
// return [
|
||||||
{
|
// {
|
||||||
source: '/tus/metrics',
|
// source: '/tus/metrics',
|
||||||
destination: 'http://localhost:1080/metrics',
|
// destination: 'http://localhost:1080/metrics',
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
source: '/tus/files',
|
// source: '/tus/files',
|
||||||
destination: 'http://localhost:1080/files',
|
// destination: 'http://localhost:1080/files',
|
||||||
},
|
// },
|
||||||
]
|
// ]
|
||||||
},
|
// },
|
||||||
|
|
||||||
|
|
||||||
async headers() {
|
async headers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user