From b9dc90df7d05aed020766693d2bfb2a9296f5933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=A4KayJayDee?= Date: Sun, 22 Jun 2025 17:29:16 +0200 Subject: [PATCH] feat(docker): ajout de la configuration Docker pour l'application Vue.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Création d'un Dockerfile pour construire et servir l'application avec Nginx - Ajout d'un fichier de configuration Nginx pour gérer les requêtes et les erreurs - Mise à jour du composant TechBadge pour améliorer la gestion des données technologiques --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ nginx.conf | 18 ++++++++++++++++++ src/components/TechBadge.vue | 17 ++++++++++------- 3 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..347383f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Stage 1: Build the Vue.js application +FROM node:22-alpine AS build-stage + +WORKDIR /app + +# Copy package.json and package-lock.json (or yarn.lock) +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of your application's source code +COPY . . + +# Build the application +# The command is taken from your "scripts" in package.json +RUN npm run build + +# Stage 2: Serve the application with a lightweight web server +FROM nginx:stable-alpine AS production-stage + +# Copy the built files from the build stage +COPY --from=build-stage /app/dist /usr/share/nginx/html + +# Copy the nginx configuration file +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Expose port 80 to the outside world +EXPOSE 80 + +# Command to run nginx in the foreground +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2c24c86 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,18 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html index.htm; + + location / { + try_files $uri $uri/ /index.html; + } + + # Optional: Add error pages + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/src/components/TechBadge.vue b/src/components/TechBadge.vue index d5fa0ba..a607b8a 100644 --- a/src/components/TechBadge.vue +++ b/src/components/TechBadge.vue @@ -18,8 +18,10 @@ const props = withDefaults(defineProps(), { const { getImageUrl } = useAssets() // Get the technology data (handle both string and object) -const techData = computed(() => { +const techData = computed((): Technology => { if (typeof props.tech === 'string') { + const techName = props.tech as string + // Create a mapping for technologies that don't match exactly const techMapping: Record = { 'Three.js': 'JavaScript', @@ -36,13 +38,14 @@ const techData = computed(() => { // Try to find the exact match first let foundTech = Object.values(techStack) .flat() - .find(t => t.name.toLowerCase() === props.tech.toLowerCase()) + .find(t => t.name.toLowerCase() === techName.toLowerCase()) // If not found, try the mapping - if (!foundTech && techMapping[props.tech]) { + if (!foundTech && techMapping[techName]) { + const mappedName = techMapping[techName] foundTech = Object.values(techStack) .flat() - .find(t => t.name.toLowerCase() === techMapping[props.tech].toLowerCase()) + .find(t => t.name.toLowerCase() === mappedName.toLowerCase()) } if (foundTech) { @@ -51,13 +54,13 @@ const techData = computed(() => { // Fallback: create a basic tech object from string return { - name: props.tech, + name: techName, image: '', // No image for unknown techs level: 'Intermediate' as const } } - return props.tech + return props.tech as Technology }) // Get the actual image URL @@ -66,7 +69,7 @@ const imageUrl = computed(() => { return getImageUrl(techData.value.image) }) -const getLevelColor = (level: string) => { +const getLevelColor = (level: Technology['level']) => { switch (level) { case 'Advanced': return 'badge-success'