Skip to content

Commit

Permalink
Refactor Dockerfile to improve security and dependency management
Browse files Browse the repository at this point in the history
  • Loading branch information
GabsBaquie committed Sep 16, 2024
1 parent d14badb commit 8e408f2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ FROM node:22.7-bookworm-slim
# Définir le répertoire de travail dans le conteneur
WORKDIR /app

# Copier les fichiers package.json et package-lock.json depuis strapi-CMS
# Copier les fichiers package.json et package-lock.json
COPY strapi-CMS/package*.json ./

# Installer les dépendances de production uniquement
RUN npm install --production
# Installer les dépendances
RUN npm install --production && npm cache clean --force

# Copier tout le contenu du répertoire strapi-CMS dans le répertoire de travail
COPY strapi-CMS .
COPY strapi-CMS ./

# Construire l'application Strapi
RUN npm run build

# Ajouter un utilisateur non-root pour des raisons de sécurité
RUN useradd -ms /bin/bash strapiuser
RUN chown -R strapiuser:strapiuser /app
USER strapiuser

# Exposer le port utilisé par Strapi
EXPOSE 1337

Expand Down

0 comments on commit 8e408f2

Please sign in to comment.