Alpine Nuxt.js Docker ~58MB

A minimal Nuxt.js Docker image based on Alpine Linux with a complete package index and only 58 MB in size!

  • alpine-nuxt
      • .dockerignore
        • Dockerfile
          • package.json
        *
        !package*.json
        .dockerignore
        ARG VERSION=11.11.0
        
        FROM mhart/alpine-node:${VERSION}
        COPY package*.json /app/
        RUN cd /app; npm ci \
          && npm run build \
          && npm ci nuxt-start --production
        COPY . /app
        
        FROM mhart/alpine-node:base-${VERSION}
        WORKDIR /app
        ENV HOST 0.0.0.0
        COPY package.json .
        COPY --from=0 ./app/node_modules ./node_modules
        COPY --from=0 ./app/.nuxt ./.nuxt
        
        EXPOSE 3000
        CMD ["node_modules/.bin/nuxt-start"]
        Dockerfile
        {
          "scripts": {
            "build": "nuxt build --modern"
          },
          "dependencies": {
            "nuxt-start": "^2.4.5"
          },
          "devDependencies": {
            "nuxt": "^2.4.5",
          }
        }
        package.json

        Build image:

        docker build -t [image_name] .

        Get the size of a Docker image:

        docker image inspect [image_name] --format='{{.Size}}'
        57980828

        Run image:

        docker run -d --name [container_name] [image_name]
        Dalibor Gogic
        Dalibor Gogic

        Specializing in open web technologies and applications, evented architectures, accessibility and UX.

        DevOops
        Progressive Web App
        GET IT ON GOOGLE PLAY