Coder Social home page Coder Social logo

dockerfile-gatsby's Introduction

Test Docker Image Size (latest semver)

Quick reference

Quick reference (cont.)

What is Gatsby?

Gatsby Official image doesn't actually provide Gatsby in a way that can be used for development via Docker.

cf. CLI / Dev image · Issue #25 · gatsbyjs/gatsby-docker

This image provides develop environment which supports:


Gatsby is a React-based open source framework for creating websites and apps. Build anything you can imagine with over 2000 plugins and performance, scalability, and security built-in by default.

How to use this image

To run gatsby new:

docker run --rm -v $(pwd -W):/workspace futureys/gatsby gatsby new <site-name> [<starter-url>]

Ex:

docker run --rm -v $(pwd -W):/workspace futureys/gatsby gatsby new hello-world-gatsby  https://github.com/gatsbyjs/gatsby-starter-hello-world

To start development, see via docker-compose.

... via docker-compose

1.

Add Dockerfile in your project to prevent to repeat installing node packages:

FROM futureys/gatsby
COPY ./package.json ./yarn.lock ./
RUN yarn install && yarn cache clean
COPY . .

2.

Add docker-compose.yml in your project to define run parameters:

version: "3.9"
services:
  web:
    build:
      context: .
    environment:
      # Gatsby also uses NODE_ENV but how effect it is not clear...
      # see: https://www.gatsbyjs.com/docs/environment-variables/
      NODE_ENV: development
    ports:
      # For gatsby develop
      - "8000:8000"
      # For gatsby serve
      - "9000:9000"
      # 9230, 9929: When start multiple instances of node app,
      #       first instance starts occupies 127.0.0.1:9229 and other instances cannot get to the port
      # see: https://dev.to/wataash/chrome-attach-debug-with-webstorm-328p
      # see: https://github.com/nodejs/node-inspect/issues/48#issuecomment-507889953
      - "9230:9230"
      - "9929:9929"
    volumes:
      # see: https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder/37898591#37898591
      - /workspace/node_modules
      - .:/workspace

3.

Update scripts develop and serve in package.json to make it accessible from outside the container:

-    "develop": "gatsby develop",
+    "develop": "gatsby develop --host=0.0.0.0",

-    "serve": "gatsby serve,
+    "serve": "gatsby serve --host=0.0.0.0",

... with Visual Studio Code

Requirement:

At first, follow the steps 1. to 3. of via docker-compose.

4.

Select Remote-Containers: Add Development Container Configuration Files... to add configuration files for Developing inside a Container.

5.

Add Prettier, ESLint, and your using extension to .devcontainer/devcontainer.json.

Ex:

    "extensions": [
        "esbenp.prettier-vscode",
        "dbaeumer.vscode-eslint"
    ]

6.

Run the Remote-Containers: Reopen in Container... command from the Command Palette (F1) or quick actions Status bar item.

cf: Developing inside a Container using Visual Studio Code Remote Development

License

View license information for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

dockerfile-gatsby's People

Contributors

yukihiko-shinoda avatar fetwar avatar

Stargazers

 avatar Lane Goldberg avatar Daniel Martínez avatar Seunghun Sunmoon Lee avatar Veselin Minev avatar Valtteri Vallius avatar

Watchers

 avatar

Forkers

durandom

dockerfile-gatsby's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.