mirror of
https://github.com/bourquep/mysa2mqtt.git
synced 2025-10-21 23:18:07 +00:00
build: Build and publish a proper CLI tool with options, also packaged as a Docker image (#2)
* Renamed environment variables * Moved MqttSettings to main.tsx * Using Commander for CLI arguments * PinoLogger * Option for json log format * Updated mysa-js-sdk to latest version * Moved options to their own module * Extracted session file management to the session module * Added deviceId meta to thermostat instance logger * Display version from package.json; added copyright * Create README.md * Build with tsup * Update .gitignore * Remove prepublishOnly npm script * Distributed CLI executable is now working * Update README.md * Dockerfile * Minify the build output * Update README.md * Create initial Github workflow * Create release.config.mjs * Read package version at run-time, not build-time * Update README.md * Create CONTRIBUTING.md * WIP: docker CI job * Trying multiple tags * Enable docker build cache * Testing the docker build cache * Dockerfile: set npm version in final stage for better caching * Testing docker build cache * Moved VERSION arg to the final build stage * Finalized the `docker` build job * Added copyright header to all source files * Specify radix when parsing integer options
This commit is contained in:
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@@ -0,0 +1,53 @@
|
||||
################################################################################
|
||||
# Builder stage
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files and install all dependencies for building
|
||||
COPY package*.json ./
|
||||
RUN npm ci --ignore-scripts
|
||||
|
||||
# Copy source code and build
|
||||
COPY src ./src
|
||||
COPY tsconfig.json .
|
||||
COPY tsup.config.cjs .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
################################################################################
|
||||
# Final stage
|
||||
FROM node:22-alpine AS final
|
||||
|
||||
ARG VERSION
|
||||
|
||||
# Metadata
|
||||
LABEL maintainer="Pascal Bourque <pascal@cosmos.moi>"
|
||||
LABEL description="Expose Mysa smart thermostats to home automation platforms via MQTT."
|
||||
LABEL org.opencontainers.image.source="https://github.com/bourquep/mysa2mqtt"
|
||||
LABEL org.opencontainers.image.description="Expose Mysa smart thermostats to home automation platforms via MQTT"
|
||||
LABEL org.opencontainers.image.licenses="MIT"
|
||||
|
||||
# Install security updates
|
||||
RUN apk --no-cache upgrade
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S mysa2mqtt -u 1001
|
||||
|
||||
# Copy package files and install production dependencies only
|
||||
COPY --from=builder /app/package*.json ./
|
||||
RUN npm version ${VERSION} --no-git-tag-version && \
|
||||
npm ci --only=production --ignore-scripts && \
|
||||
npm cache clean --force
|
||||
|
||||
# Copy built application
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Change ownership to non-root user
|
||||
RUN chown -R mysa2mqtt:nodejs /app
|
||||
USER mysa2mqtt
|
||||
|
||||
ENTRYPOINT ["node", "dist/main.js"]
|
Reference in New Issue
Block a user