Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active December 22, 2019 08:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daliborgogic/b6d9d487420ed1c2ad8b427965a50081 to your computer and use it in GitHub Desktop.
Save daliborgogic/b6d9d487420ed1c2ad8b427965a50081 to your computer and use it in GitHub Desktop.
Mnml Nuxt.js Docker ~57.5MB
*
!assets
!pages
!static
!nuxt.config.js
!package*.json
FROM mhart/alpine-node:10.10.0
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build
# Magic!
RUN npm ci nuxt-start-edge debug --production
FROM mhart/alpine-node:base-10.10.0
WORKDIR /app
ENV NODE_ENV production
ENV HOST 0.0.0.0
ENV PORT 3000
COPY package.json .
COPY nuxt.config.js .
COPY --from=0 ./app/node_modules ./node_modules
COPY --from=0 ./app/.nuxt ./.nuxt
COPY --from=0 ./app/static ./static
EXPOSE 3000
CMD ["node_modules/nuxt-start-edge/bin/nuxt-start"]
{
"name": "mnml",
"version": "1.0.0",
"description": "Mnml Nuxt.js Docker",
"scripts": {
"dev": "node_modules/.bin/nuxt",
"build": "node_modules/.bin/nuxt build",
"start": "node_modules/nuxt-start-edge/bin/nuxt-start"
},
"dependencies": {
"debug": "^4.0.1",
"nuxt-start-edge": "^2.0.0-25615151.226b90d"
},
"devDependencies": {
"nuxt-edge": "^2.0.0-25615151.226b90d",
}
}
@daliborgogic
Copy link
Author

daliborgogic commented Sep 14, 2018

REPOSITORY                TAG                  IMAGE ID               CREATED            SIZE
mnml                   latest              96f5357ef8fc         9 seconds ago        57.5.3MB

@daliborgogic
Copy link
Author

daliborgogic commented Sep 14, 2018

$ docker exec -i -t mnml /bin/sh
/app # du -h node_modules/
...
23.1M   node_modules/

@daliborgogic
Copy link
Author

daliborgogic commented Sep 2, 2019

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mnml             latest                9c3a50fb7ab5        3 minutes ago       54.6MB

Dockerfile

ARG VERSION=12.9.1

FROM mhart/alpine-node:${VERSION} AS dev
WORKDIR /app
COPY package*.json .gitignore ./
ENV HOST=0.0.0.0

RUN npm ci --prefer-offline --no-audit
COPY . ./app/
EXPOSE 3000
CMD ["node_modules/.bin/nuxt"]

FROM dev AS test
RUN npm run lint && npm test

FROM test AS build
RUN npm run build \
  && npm ci --prefer-offline --no-audit --prod \
  && cp -R node_modules prod_node_modules

FROM mhart/alpine-node:slim-${VERSION} AS release
ENV HOST=0.0.0.0
COPY --from=build /app/prod_node_modules ./node_modules
COPY --from=build /app/.nuxt ./.nuxt
EXPOSE 3000
CMD ["node_modules/.bin/nuxt-start"]

package.json

{
  "name": "mnml",
  "version": "0.1.0",
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build --modern",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
    "test": "echo \"WARN: no test specified 😁\" && exit 0",
    "start": "nuxt-start"
  },
  "dependencies": {
    "nuxt-start": "^2.9.2"
  },
  "devDependencies": {
    "nuxt": "^2.9.2",
    "postcss-nested": "^4.1.2",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-vue": "^5.2.2"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "browser": true,
      "node": true
    },
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "extends": [
      "eslint:recommended",
      "plugin:vue/recommended"
    ],
    "plugins": [
      "vue"
    ],
    "rules": {
      "semi": [
        2,
        "never"
      ],
      "no-console": "error",
      "vue/max-attributes-per-line": "off"
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment