wayfair-incubator / aux-eng-playbook

Wayfair Tech's playbook for building and supporting an Auxiliary Engineering program.
BSD Zero Clause License
4 stars 1 forks source link

🐳 Configure Docker for Gatsby + Yarn #25

Closed lelia closed 2 years ago

lelia commented 2 years ago

Fixes #5.

Changes

Confirmed gatsby cleanly builds and runs without issue in a container via docker-compose build develop && docker-compose up develop:

[+] Building 1.1s (13/13) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                             0.0s
 => => transferring dockerfile: 1.87kB                                                                                                                                                                           0.0s
 => [internal] load .dockerignore                                                                                                                                                                                0.0s
 => => transferring context: 35B                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/node:16-alpine3.15                                                                                                                                            0.6s

 [...]

 => exporting to image                                                                                                                                                                                           0.2s
 => => exporting layers                                                                                                                                                                                          0.2s
 => => writing image sha256:9edaafb57bc2d38335c7a6881fd045b1993513a1cb5d65fcb5772fba3bb2cbaa                                                                                                                     0.0s
 => => naming to docker.io/library/auxeng-docs_develop                                                                                                                                                           0.0s

[...]

[+] Running 2/0
 ⠿ Network auxeng-docs_default      Created                                                                                                                                                                      0.0s
 ⠿ Container auxeng-docs-develop-1  Created                                                                                                                                                                      0.0s
Attaching to auxeng-docs-develop-1
auxeng-docs-develop-1  | success compile gatsby files - 1.308s

[...]

success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 0.830s - 9/9 10.85/s
⠀
You can now view auxeng-docs in the browser.
⠀
  Local:            http://localhost:8000/
  On Your Network:  http://192.168.0.2:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  Local:            http://localhost:8000/___graphql
  On Your Network:  http://192.168.0.2:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 20.909s
success Writing page-data.json files to public directory - 0.092s - 3/26
auxeng-docs-develop-1  | 283.89/s
auxeng-docs-develop-1  |

Also confirmed the gastby CLI works via docker-compose run gatsby info:

  System:
    OS: Linux 5.10 Alpine Linux
    CPU: (5) arm64 unknown
    Shell: 1.34.1 - /bin/ash
  Binaries:
    Node: 16.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
  npmPackages:
    gatsby: 4.19.2 => 4.19.2
    gatsby-cli: 4.19.0 => 4.19.0

[...]

    gatsby-transformer-remark: 5.19.0 => 5.19.0
    gatsby-transformer-sharp: 4.19.0 => 4.19.0

NOTE: I was unable to find a way to keep the volumes section in docker-compose.yml without running into subsequent yarn build errors, even when including COPY instructions within the Dockerfile and accounting for relative/absolute pathing, etc. So, the configuration as-is will likely not support hot-reloads, but we could always file this as a future enhancement and still get some degree of Docker functionality in the meantime.