Skip to content
Open
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
54 changes: 43 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
# build stage
FROM node:lts-alpine AS build-stage
# Set environment variables for non-interactive npm installs
ENV NPM_CONFIG_LOGLEVEL warn
ENV CI true
# ── Stage 1: Build the Vue frontend ──────────────────────────────────────────
FROM node:20-alpine AS build-stage

ENV NPM_CONFIG_LOGLEVEL=warn
ENV CI=true

WORKDIR /app

RUN npm install -g pnpm@9.11.0

COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm i --frozen-lockfile
RUN pnpm install --frozen-lockfile

COPY . .
RUN pnpm build
RUN NODE_OPTIONS=--max_old_space_size=4096 pnpm exec vite build

# ── Stage 2: Production image (nginx + API server) ───────────────────────────
FROM node:20-alpine AS production

Check warning on line 18 in Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

The "node" image runs with "root" as the default user. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=CorentinTh_it-tools&issues=AZ7eFABLL49KgC-o6ILS&open=AZ7eFABLL49KgC-o6ILS&pullRequest=1819

Check notice

Code scanning / SonarCloud

Docker containers should not run as a privileged user Low

The "node" image runs with "root" as the default user. Make sure it is safe here. See more on SonarQube Cloud

WORKDIR /app

# Install nginx alongside Node.js
RUN apk add --no-cache nginx

Check warning on line 23 in Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this RUN instruction with the consecutive ones.

See more on https://sonarcloud.io/project/issues?id=CorentinTh_it-tools&issues=AZ7eFABLL49KgC-o6ILR&open=AZ7eFABLL49KgC-o6ILR&pullRequest=1819

# production stage
FROM nginx:stable-alpine AS production-stage
RUN npm install -g pnpm@9.11.0

# Copy package manifests and tsconfig for server
COPY package.json pnpm-lock.yaml tsconfig.server.json ./

# Install all deps (tsx is a devDep needed at runtime)
RUN pnpm install --frozen-lockfile

# Copy server source and the src/ files the server imports
COPY server/ ./server/
COPY src/ ./src/

# Copy built Vue frontend from build stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Copy nginx config
COPY nginx.conf /etc/nginx/http.d/default.conf

# Expose HTTP port
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

ENV API_PORT=3001

# Start nginx + API server
CMD sh -c "nginx && pnpm api:start"

Check warning on line 49 in Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Consider wrapping this instruction in a script file and call it with exec form.

See more on https://sonarcloud.io/project/issues?id=CorentinTh_it-tools&issues=AZ7eFABLL49KgC-o6ILT&open=AZ7eFABLL49KgC-o6ILT&pullRequest=1819
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
it-tools:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80"
restart: unless-stopped
environment:
- API_PORT=3001
Loading
Loading