0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Nuxtをマルチステージビルドでコンテナ化する

Last updated at Posted at 2021-06-21

はじめに

Nuxtをコンテナ化したときの覚書です。

マルチステージビルド

前提省きますが、一般的なNuxtの構成です。

Dockerfile.
FROM node:14.4.0-alpine as builder
WORKDIR /app
ADD . ./
RUN yarn install
RUN yarn build

FROM node:14.4.0-alpine
WORKDIR /app
ENV HOST=0.0.0.0
ADD package*.json ./
ADD nuxt.config.js ./
COPY --from=builder ./app/src ./src/
COPY --from=builder ./app/node_modules ./node_modules/
COPY --from=builder ./app/.nuxt ./.nuxt/
EXPOSE 3000

CMD ["yarn", "start"]

Docker run

docker build -t <image-name> .
docker run -p 3000:3000 <image-name>

参考にさせていただいたもの

私はただコピペしただけです。多謝。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?