add dockerfile

This commit is contained in:
Milovann Yanatchkov 2025-11-21 21:09:09 +01:00
parent 05819cebfb
commit 85562d5406
2 changed files with 66 additions and 0 deletions

41
viewer/src/Dockerfile Normal file
View file

@ -0,0 +1,41 @@
# Use Node.js 20 as base image
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy source code
COPY . .
# Install dev dependencies for building
RUN npm ci
# Build the viewer and CLI
RUN npm run build-viewer
RUN npm run pkg-cli
# Production stage
FROM node:20-alpine AS production
# Install serve for web viewer
RUN npm install -g serve
# Set working directory
WORKDIR /app
# Copy built files from builder stage
COPY --from=builder /web/viewer ./web/viewer
COPY --from=builder /app/ifcx-cli.js ./
COPY --from=builder /app/ifcx.exe ./
# Expose port for web viewer
EXPOSE 3000
# Default command serves the web viewer
CMD ["serve", "web/viewer", "-l", "3000"]

25
viewer/src/Makefile Normal file
View file

@ -0,0 +1,25 @@
.PHONY: build run clean help
# Default target
help:
@echo "Available targets:"
@echo " build - Build the Docker image"
@echo " run - Run the Docker container"
@echo " clean - Remove the Docker image"
@echo " shell - Run interactive shell in container"
# Build the Docker image
build:
docker build -t ifc5-viewer .
# Run the Docker container
run:
docker run -it --rm -p 3000:3000 ifc5-viewer
# Run interactive shell in container
shell:
docker run -it --rm ifc5-viewer /bin/bash
# Clean up Docker image
clean:
docker rmi ifc5-viewer