MicrosoftDocs / mslearn-aks-deployment-pipeline-github-actions

Sample code for the MS Learn module for AKS with GitHub Actions
Creative Commons Attribution 4.0 International
18 stars 677 forks source link

Failed to build docker #27

Open emmanuel-libertechy opened 2 months ago

emmanuel-libertechy commented 2 months ago

Encountered the error below



Dockerfile:7

5 | RUN git submodule update --init themes/introduction 6 | >>> RUN hugo && mv public/* /usr/share/nginx/html 7 | EXPOSE 80 8 |

ERROR: failed to solve: process "/bin/sh -c hugo && mv public/ /usr/share/nginx/html" did not complete successfully: exit code: 255 Error: buildx failed with: ERROR: failed to solve: process "/bin/sh -c hugo && mv public/ /usr/share/nginx/html" did not complete successfully: exit code: 255

Cause of the error: The error is due to the use of the nullish coalescing assignment operator (??=), which is a relatively new JavaScript feature not supported by the version of Node.js in use in the Docker image.

Solution: Updated the Dockerfile to the below: FROM nginx:1.18

Install dependencies, including a newer Node.js version and other required tools

RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get update -y && \ apt-get install -y git curl nodejs && \ curl -sL https://github.com/gohugoio/hugo/releases/download/v0.72.0/hugo_extended_0.72.0_Linux-64bit.tar.gz | tar -xz hugo && \ mv hugo /usr/bin && \ npm install -g postcss-cli autoprefixer postcss

Clone the repository

RUN git clone https://github.com/MicrosoftDocs/mslearn-aks-deployment-pipeline-github-actions /contoso-website

Set the working directory

WORKDIR /contoso-website/src

Initialize and update git submodules

RUN git submodule update --init themes/introduction

Update npm packages

RUN npm update

Build the Hugo site and move the generated files to the Nginx html directory

RUN hugo && mv public/* /usr/share/nginx/html

Expose port 80

EXPOSE 80