Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce413cf6bc |
10
Dockerfile
10
Dockerfile
@@ -13,9 +13,16 @@ RUN npm ci
|
|||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install git to extract version information
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Extract version from git
|
||||||
|
RUN git describe --tags --always 2>/dev/null > /tmp/version.txt || echo "unknown" > /tmp/version.txt
|
||||||
|
|
||||||
# Next.js collects completely anonymous telemetry data about general usage.
|
# Next.js collects completely anonymous telemetry data about general usage.
|
||||||
# Learn more here: https://nextjs.org/telemetry
|
# Learn more here: https://nextjs.org/telemetry
|
||||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||||
@@ -53,6 +60,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|||||||
# Create uploads directory and set permissions
|
# Create uploads directory and set permissions
|
||||||
RUN mkdir -p public/uploads/covers && chown -R nextjs:nodejs public/uploads
|
RUN mkdir -p public/uploads/covers && chown -R nextjs:nodejs public/uploads
|
||||||
|
|
||||||
|
# Copy version file from builder
|
||||||
|
COPY --from=builder /tmp/version.txt /app/version.txt
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import { execSync } from 'child_process';
|
|||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
|
// First check if version is set via environment variable (Docker build)
|
||||||
|
if (process.env.APP_VERSION) {
|
||||||
|
return NextResponse.json({ version: process.env.APP_VERSION });
|
||||||
|
}
|
||||||
|
|
||||||
// Try to get the git tag/version
|
// Try to get the git tag/version
|
||||||
let version = 'dev';
|
let version = 'dev';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Export version if available
|
||||||
|
if [ -f /app/version.txt ]; then
|
||||||
|
export APP_VERSION=$(cat /app/version.txt)
|
||||||
|
echo "App version: $APP_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Starting deployment..."
|
echo "Starting deployment..."
|
||||||
|
|
||||||
# Run migrations
|
# Run migrations
|
||||||
|
|||||||
Reference in New Issue
Block a user