Alpine Nuxt.js Docker ~58MB
Dalibor Gogic
A minimal Nuxt.js Docker image based on Alpine Linux with a complete package index and only ~58 MB in size!
.dockerignore
*
!package*.json
Dockerfile
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"]
package.json
{
"scripts": {
"build": "nuxt build --modern"
},
"dependencies": {
"nuxt-start": "^2.4.5"
},
"devDependencies": {
"nuxt": "^2.4.5",
}
}
cmd
# 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]