Until you build a Nuxt.js development environment with Docker and touch it with VS Code

If you buy a new Macbook and create a development environment with a Docker container, it will be easy to match the environment with other people, and I thought that it would be good if my Macbook environment was not polluted, so it is a memorandum.

I would be grateful if you could let me know if you should do this or if there is any incorrect information. ~~ I'm just touching Vue.js lightly, so I'm scared because I don't understand the infrastructure, but I want to do my best. .. ~~

Premise

--Apple M1 chip MacBook Air (macOS Big Sur, 16GB)

Thing you want to do

  1. You can build an environment where you can develop Nuxt.js on Docker
  2. You can access Nuxt.js applications from your Mac
  3. I want to develop from VS Code on Mac

Articles that I used as a reference

-Just build nuxt.js development environment with docker -Create nuxt development environment with docker -[Docker] I built a Nuxt development environment with Dockerfile and docker-compose.yml!

memorandum

1. Create a Docker image

Since there was a node official Docker image, create a Docker image using that. As of December 25, 2020, the stable version was 14.15.3, so I decided to use that.

Dockerfile


FROM node:lts-alpine3.11

WORKDIR /app

RUN apk update && \
    apk add git && \
    npm install -g npm && \
    npm install -g vue-cli && \
    npm install -g [email protected]

ENV HOST 0.0.0.0
EXPOSE 8080

The base Docker image is specified in FROM.

WORKDIR/app is like cd/app on a Docker container.

RUN actually hits the command.

create-nuxt-app seems to give the following error when the latest version is installed, and it seems that it will work if the version is dropped a little (@ 2.15.0) (see the reference article).

Can't create . because there's already a non-empty directory . existing in path.

docker-compose.yml


version: '3'
services: 
  nuxt:
    build: .
    tty: true
    command: npm run dev
    volumes:
      - .:/app
    ports:
      - "8080:3000"

By specifying " 8080: 3000 " in ports, you can refer to localhost: 3000 in the container by looking at localhost: 8080 on the outside (in this case, Mac side).

2. Launch the Docker container

Build the created image and launch the container.

$ docker-compose build
$ docker images
REPOSITORY   TAG              IMAGE ID       CREATED          SIZE
nuxt_nuxt    latest           53cf2fd02c9a   39 seconds ago   210MB
node         lts-alpine3.11   66ba137c0d00   6 days ago       115MB

Each item of create-nuxt-app is left to you.

$ docker-compose run --rm nuxt npx create-nuxt-app
create-nuxt-app v2.15.0
✨  Generating Nuxt.js project in .
? Project name app
? Project description nuxt.js sample app
? Author name trajanme
? Choose programming language JavaScript
? Choose the package manager Yarn
? Choose UI framework None
? Choose custom server framework None (Recommended)
? Choose Nuxt.js modules Progressive Web App (PWA) Support
? Choose linting tools ESLint
? Choose test framework None
? Choose rendering mode Single Page App
? Choose development tools jsconfig.json (Recommended for VS Code)
docker-compose up -d

Now you can see the application by going to http: // localhost: 8080.

スクリーンショット 2020-12-26 0.22.38.png

I got an ESLint error, but I confirmed the startup for the time being.

3. Edit the container file from VS Code on Mac

It was really easy.

I was wondering if I would use ** Remote-Containers ** as described in the article Use Docker Development Container Conveniently with VS Code ...

スクリーンショット 2020-12-26 0.11.48.png

Just press "Open in Visual Studio Code" of the container launched from "Containers/Apps" of the Docker application.

スクリーンショット 2020-12-26 0.13.15.png

By the way, to drop the Docker container, use the following command.

$ docker-compose down

If you raise it again, you can work normally from the previous continuation.

It's often unclear if I don't investigate a little more, so I want to organize it during the year-end and New Year holidays ...

Recommended Posts

Until you build a Nuxt.js development environment with Docker and touch it with VS Code
Build a Java development environment with VS Code
Build Java development environment with WSL2 Docker VS Code
[Environment construction] Build a Java development environment with VS Code!
Build a PureScript development environment with Docker
Build a Wordpress development environment with Docker
Build a WordPress development environment quickly with Docker
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
Build Java development environment with VS Code on Mac
How to build Java development environment with VS Code
Build a Node.js environment with Docker
Create a Java (Gradle) project with VS Code and develop it on a Docker container
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Build a Node-RED environment with Docker to move and understand
Create a Java (Maven) project with VS Code and develop it on a Docker container
Until you build a project described in scala with Maven and execute it with the scala command.
Until you build the docker environment and start / stop the Ubuntu container
Building a haskell environment with Docker + VS Code on Windows 10 Home
Build a development environment for Django + MySQL + nginx with Docker Compose
Prepare Java development environment with VS Code
Build a simple Docker + Django development environment
[Be careful about changing the version of Xdebug! ] Create a development environment with Xdebug3 + docker + VS Code
I tried to build a Firebase application development environment with Docker in 2020
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a Laravel / Docker environment with VSCode devcontainer
Build a simple Docker Compose + Django development environment
[Win10] Build a JSF development environment with NetBeans
Prepare a scraping environment with Docker and Java
A reminder of Docker and development environment construction
Build a development environment for Docker, java, vscode
[First team development ②] Build an environment with Docker
Create a Spring Boot development environment with docker
Build a Docker-based development environment on Windows 10 Home 2020 ver. Part 2 VS Code should make the Docker development environment comfortable
Build a web application development environment that uses Java, MySQL, and Redis with Docker CE for Windows
Build a Doker-based development environment on Windows 10 Home 2020 ver. Part 1 Until WSL2-based Docker build
Build a development environment to create Ruby on Jets + React apps with Docker
Easily build a Vue.js environment with Docker + Vue CLI
Build ruby debug environment with VS Code of Windows 10
Introduce JavaFX 15 and do GUI development with VS Code
[Note] Build a Python3 environment with Docker in EC2
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
Try to build a Java development environment using Docker
Build Java program development environment with Visual Studio Code
Build a local development environment for Open Distro for Elasticsearch with multiple nodes using Docker
Docker management with VS Code
Build docker environment with WSL
I made a development environment with rails6 + docker + postgreSQL + Materialize.
[Docker] Build a site on Hugo and publish it on GitHub
Java web application development environment construction with VS Code (struts2)
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
How to build Rails, Postgres, ElasticSearch development environment with Docker
I tried to create a padrino development environment with Docker
Build WebAPP development environment with Java + Spring with Visual Studio Code