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
79 changes: 13 additions & 66 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,77 +1,24 @@
# Build stage
FROM node:20-alpine AS builder

# Install build dependencies for node-gyp and native modules
RUN apk add --no-cache \
python3 \
py3-pip \
make \
g++ \
sqlite-dev \
pkgconfig

# Set environment variable for node-gyp to find Python
ENV PYTHON=/usr/bin/python3

# Install distutils for Python (required by node-gyp)
RUN pip3 install --break-system-packages setuptools
FROM node:20-alpine

# Create working directory
WORKDIR /opt/app

# Copy dependency files
COPY package*.json ./
COPY babel.config.js tsconfig.json ./

# Configure npm for better Docker builds
RUN npm config set unsafe-perm true

# Install all dependencies (including dev dependencies for build)
RUN npm ci
RUN apk add --no-cache alpine-sdk cmake python3 openssl-dev

# Copy source code
# Copy and install dependencies
COPY package.json .
COPY package-lock.json .
COPY babel.config.js .
COPY tsconfig.json .
COPY .env .
COPY src ./src
RUN npm install

# Build the project
# Build project
RUN npm run build

# Runtime stage
FROM node:20-alpine AS runtime

# Install runtime dependencies only
RUN apk add --no-cache \
python3 \
py3-pip \
sqlite

# Set environment variable for node-gyp to find Python
ENV PYTHON=/usr/bin/python3

# Install distutils for Python (required by some runtime native modules)
RUN pip3 install --break-system-packages setuptools

# Create working directory
WORKDIR /opt/app

# Copy package files
COPY package*.json ./

# Configure npm
RUN npm config set unsafe-perm true

# Install only production dependencies
RUN npm ci --only=production && npm cache clean --force

# Copy built application from builder stage
COPY --from=builder /opt/app/dist ./dist

# Copy other necessary files
COPY src/views ./src/views
COPY src/public ./src/public

# Copy .env file if it exists
COPY .env* ./

# Expose application port
EXPOSE 3000

CMD ["npm", "start"]
# Start app
CMD [ "npm", "start" ]
Loading