Files
cannaiq/backend/Dockerfile
Kelly 68430f5c22
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
fix(ci): Use mirror.gcr.io as registry mirror for Kaniko
2025-12-15 18:52:02 -07:00

78 lines
1.9 KiB
Docker

# Build stage
# Image: git.spdy.io/creationshop/dispensary-scraper
FROM node:22-slim AS builder
# Install build tools for native modules (bcrypt, sharp)
RUN apt-get update && apt-get install -y \
python3 \
build-essential \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package*.json ./
# Install dependencies with retry and fallback registry
RUN npm config set fetch-retries 3 && \
npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000 && \
npm install || \
(npm config set registry https://registry.npmmirror.com && npm install)
COPY . .
RUN npm run build
# Prune dev dependencies for smaller production image
RUN npm prune --production
# Production stage
FROM node:22-slim
# Build arguments for version info
ARG APP_BUILD_VERSION=dev
ARG APP_GIT_SHA=unknown
ARG APP_BUILD_TIME=unknown
ARG CONTAINER_IMAGE_TAG=local
# Set version info as environment variables
ENV APP_BUILD_VERSION=${APP_BUILD_VERSION}
ENV APP_GIT_SHA=${APP_GIT_SHA}
ENV APP_BUILD_TIME=${APP_BUILD_TIME}
ENV CONTAINER_IMAGE_TAG=${CONTAINER_IMAGE_TAG}
# Install Chromium dependencies and curl for HTTP requests
RUN apt-get update && apt-get install -y \
curl \
chromium \
fonts-liberation \
libnss3 \
libxss1 \
libasound2 \
libatk-bridge2.0-0 \
libgtk-3-0 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
WORKDIR /app
COPY package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
# Copy migrations for auto-migrate on startup
COPY migrations ./migrations
# Create local images directory for when MinIO is not configured
RUN mkdir -p /app/public/images/products
# Copy static downloads (plugin files, etc.)
COPY public/downloads /app/public/downloads
EXPOSE 3010
CMD ["node", "dist/index.js"]