chore: plug in minio storage

This commit is contained in:
2025-12-02 12:58:08 +01:00
parent 0cf6b405f1
commit 79b8535304
3 changed files with 45 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ FROM node:20-alpine AS base
# Install dependencies only when needed # Install dependencies only when needed
FROM base AS deps FROM base AS deps
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat wget
WORKDIR /app WORKDIR /app
# Install pnpm # Install pnpm
@@ -45,6 +45,10 @@ COPY --from=builder /app/public ./public
RUN mkdir .next RUN mkdir .next
RUN chown nextjs:nodejs .next RUN chown nextjs:nodejs .next
# Copy entrypoint script
COPY --from=builder --chown=nextjs:nodejs /app/docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x ./docker-entrypoint.sh
# Automatically leverage output traces to reduce image size # Automatically leverage output traces to reduce image size
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
@@ -56,4 +60,5 @@ EXPOSE 3000
ENV PORT=3000 ENV PORT=3000
ENV HOSTNAME="0.0.0.0" ENV HOSTNAME="0.0.0.0"
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["node", "server.js"] CMD ["node", "server.js"]

View File

@@ -42,6 +42,22 @@ services:
timeout: 5s timeout: 5s
retries: 5 retries: 5
minio-setup:
image: minio/mc:latest
container_name: meal-planner-minio-setup
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
mc alias set myminio http://minio:9000 minioadmin minioadmin;
mc mb myminio/meal-planner --ignore-existing;
mc anonymous set download myminio/meal-planner;
echo 'MinIO bucket setup complete';
"
networks:
- meal-planner-network
app: app:
build: build:
context: . context: .
@@ -54,6 +70,12 @@ services:
PAYLOAD_PUBLIC_SERVER_URL: http://localhost:3100 PAYLOAD_PUBLIC_SERVER_URL: http://localhost:3100
SEED_DB: "true" SEED_DB: "true"
NODE_ENV: production NODE_ENV: production
# MinIO/S3 configuration
MINIO_ENDPOINT: http://minio:9000
S3_BUCKET: meal-planner
S3_REGION: us-east-1
S3_ACCESS_KEY_ID: minioadmin
S3_SECRET_ACCESS_KEY: minioadmin
ports: ports:
- "3100:3000" - "3100:3000"
depends_on: depends_on:
@@ -61,6 +83,8 @@ services:
condition: service_healthy condition: service_healthy
minio: minio:
condition: service_healthy condition: service_healthy
minio-setup:
condition: service_completed_successfully
networks: networks:
- meal-planner-network - meal-planner-network

15
docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
set -e
# Wait for MinIO to be ready
if [ -n "$MINIO_ENDPOINT" ]; then
echo "Waiting for MinIO to be ready..."
until wget -q --spider "$MINIO_ENDPOINT/minio/health/live" 2>/dev/null; do
echo "MinIO is unavailable - sleeping"
sleep 2
done
echo "MinIO is up"
fi
# Start the application
exec "$@"