Gats by new with yarn (Docker)

In the Docker environment (I haven't checked other environments), when you do gatsby new orgatsby new ~, ** npm installation ** will be done without any questions.

Here's how to use yarn to gats by new!

Development environment

Confirmation of directory structure after completion

    |- .config
        |- gatsby
            |- config.json
    |-Generated gatsby files
        |- ...
    |- docker-compose.yml
    |- Dockerfile

Prepare in advance other than the generated gatsby files described above.

Create config.json

This is the way to use yarn. ↓ See here for details ↓ Using Yarn as your Gatsby package manager

Create config.json according to the previous configuration, and write the following with reference to the official document.


	"cli": {
		"packageManager": "yarn"

Docker system settings

The configuration is as follows to connect the settings of config.json with the settings in the container.


FROM node:12.17.0

RUN mkdir project-name
WORKDIR /project-name
COPY .config /root/.config/

RUN yarn global add gatsby-cli

Then it becomes the docker-compose file


version: '3.8'
    build: ./
    tty: true
    stdin_open: true
      - ./:/project-name
      - NODE_ENV=development
      - 8000:8000
      - 9000:9000


Create an image, start the container, and go inside the container.

$ docker-compose build
$ docker-compose up -d
$ docker-compose exec gatsby bash

Let's go see if the file exists in the container once!

$ cat /root/.config/gatsby/config.json

If you have the config.json you created earlier, you're successful!

Then try gats by new ~!

$gatsby new Folder name of the generated gatsby files

** It should have been created by yarn! !! ** **

at the end

I've been searching for various articles and looking for a way to create them with just yarn, and I found one, so I shared it!

Note that the config.json file contains values ​​that I didn't understand well, so it may be better to ignore the main body when pushing and create config.example.json etc. Hmm.

Recommended Posts

Gats by new with yarn (Docker)
Launch MariaDB with Docker
Rails deploy with Docker
Run Pico with docker
Explode Docker with WSL2
Use Puphpeteer with Docker
[ARM64] Docker server monitoring with New Relic on Docker on RasPi4
Operate Emby with Docker
Try WildFly with Docker
Use ngrok with Docker
Run Payara with Docker
[Docker] Connection with MySQL
Php settings with Docker
Getting Started with Docker
Disposable PHP with Docker
Install Composer with Docker
Get the URL issued by ngrok with the Docker expose plugin
Pytorch execution environment with Docker
Use GDAL with Python with Docker
Run TAO Core with Docker
Docker management with VS Code
Install yarn in docker image
Set up GitLab with docker
Generation gap with new engineers
Run Rails whenever with docker
Docker autostart settings with wsl2
[Docker] Rails 5.2 environment construction with docker
Spring Boot starting with Docker
Build docker environment with WSL
Web application built with docker (1)
I tried BIND with Docker
React environment construction with Docker
Build DynamoDB local with Docker
[Docker] Use whenever with Docker + Rails
Using PlantUml with Honkit [Docker]