feat: add Docker build
This commit is contained in:
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.cursor
|
||||||
|
*.md
|
||||||
|
node_modules
|
||||||
|
README.md
|
||||||
|
docs
|
||||||
|
|
||||||
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm ci --only=production
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
|
# Install wget for health checks
|
||||||
|
RUN apk --no-cache add wget
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy dependencies from builder
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
|
COPY package*.json ./
|
||||||
|
COPY server ./server
|
||||||
|
COPY presets ./presets
|
||||||
|
COPY public ./public
|
||||||
|
|
||||||
|
# Create non-root user (let Alpine assign available GID/UID)
|
||||||
|
RUN addgroup spore && \
|
||||||
|
adduser -D -s /bin/sh -G spore spore && \
|
||||||
|
chown -R spore:spore /app
|
||||||
|
|
||||||
|
USER spore
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
CMD ["node", "server/index.js"]
|
||||||
|
|
||||||
40
Makefile
Normal file
40
Makefile
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
.PHONY: install build run clean docker-build docker-run docker-push
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
install:
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Build the application (if needed)
|
||||||
|
build: install
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
run:
|
||||||
|
node server/index.js
|
||||||
|
|
||||||
|
# Start in development mode
|
||||||
|
dev:
|
||||||
|
node server/index.js
|
||||||
|
|
||||||
|
# Clean build artifacts
|
||||||
|
clean:
|
||||||
|
rm -rf node_modules
|
||||||
|
rm -f package-lock.json
|
||||||
|
|
||||||
|
# Docker variables
|
||||||
|
DOCKER_REGISTRY ?=
|
||||||
|
IMAGE_NAME = wirelos/spore-ledlab
|
||||||
|
IMAGE_TAG ?= latest
|
||||||
|
FULL_IMAGE_NAME = $(if $(DOCKER_REGISTRY),$(DOCKER_REGISTRY)/$(IMAGE_NAME),$(IMAGE_NAME)):$(IMAGE_TAG)
|
||||||
|
|
||||||
|
# Build Docker image
|
||||||
|
docker-build:
|
||||||
|
docker build -t $(FULL_IMAGE_NAME) .
|
||||||
|
|
||||||
|
# Run Docker container
|
||||||
|
docker-run:
|
||||||
|
docker run -p 8080:8080 --rm $(FULL_IMAGE_NAME)
|
||||||
|
|
||||||
|
# Push Docker image
|
||||||
|
docker-push:
|
||||||
|
docker push $(FULL_IMAGE_NAME)
|
||||||
|
|
||||||
Reference in New Issue
Block a user