Coder Social home page Coder Social logo

Comments (16)

gardner avatar gardner commented on June 12, 2024 14

This issue is still reproducible and prevents new users from being able to make use of the docker image.

Steps to reproduce:

mytmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'devreprogatsby')
cd $mytmpdir

npm i -g gatsby-cli
gatsby new gardner
cd gardner/

cat << EOF > .dockerignore
.cache/
node_modules/
public/
EOF

cat << EOF > Dockerfile
FROM gatsbyjs/gatsby:onbuild as build

FROM gatsbyjs/gatsby
COPY --from=build /app/public /pub
EOF

gatsby build

docker build -t gh-issue-39 .

echo "Be sure to remove the temporary files: "
echo rm -rf $mytmpdir

This results in:

Sending build context to Docker daemon  1.519MB
Step 1/3 : FROM gatsbyjs/gatsby:onbuild as build
# Executing 1 build trigger
ADD failed: stat /var/lib/docker/tmp/docker-builder209143335/public: no such file or directory

from gatsby-docker.

MasaSip avatar MasaSip commented on June 12, 2024 7

I am pretty sure the problem is that the onbuild tag on docker hub contains the same image like the latest tag, which it should not. It is supposed to contain the result of https://github.com/gatsbyjs/gatsby-docker/blob/master/Dockerfile.onbuild but it does not. Instead both images are a result of https://github.com/gatsbyjs/gatsby-docker/blob/master/Dockerfile which is only supposed to be used for the latest tag.
The issue @shicholas linked (#38) contains the right workarounds for this issue. (Another option is to use the Dockerfile.onbuild from this repo and build it yourself.)

I totally agree with this. My solution was to build the image and host it in docker hub. If someone wants to use it as well, just replace
FROM gatsbyjs/gatsby:onbuild as build
with
FROM masasip/gatsby:onbuild as build

To repleat my steps and host image on your own, create a repo to docker hub and then run locally:

git clone [email protected]:gatsbyjs/gatsby-docker.git
cd gatsby-docker
docker build -t gatsby:onbuild --file Dockerfile.onbuild .
docker login --username=<your-docker-hub-username>
docker tag gatsby:onbuild <your-docker-hub-username>/<your-docker-hub-repo>:onbuild
docker push <your-docker-hub-username>/<your-docker-hub-repo>:onbuild

and replace
FROM gatsbyjs/gatsby:onbuild as build
with
<your-docker-hub-username>/<your-docker-hub-repo>:onbuild

from gatsby-docker.

NogaMan avatar NogaMan commented on June 12, 2024 6

I solved the problem by doing a custom Dockerfile based on nginx image.
My Dockerfile and my nginx config are in this public gist https://gist.github.com/NogaMan/3ae6bd88e8ae063ab6da56bc36659c7d

The files are working 100%

from gatsby-docker.

ekeih avatar ekeih commented on June 12, 2024 5

I am pretty sure the problem is that the onbuild tag on docker hub contains the same image like the latest tag, which it should not. It is supposed to contain the result of https://github.com/gatsbyjs/gatsby-docker/blob/master/Dockerfile.onbuild but it does not. Instead both images are a result of https://github.com/gatsbyjs/gatsby-docker/blob/master/Dockerfile which is only supposed to be used for the latest tag.
The issue @shicholas linked (#38) contains the right workarounds for this issue. (Another option is to use the Dockerfile.onbuild from this repo and build it yourself.)

from gatsby-docker.

Olegt0rr avatar Olegt0rr commented on June 12, 2024 3

Any news about fixing this bug?

from gatsby-docker.

shicholas avatar shicholas commented on June 12, 2024 1

hmm, I'm not sure what your issue is then. given that this docker image hasn't been updated in a while, I shared a solution (and there are others) on this thread - #38 (comment) hope either solution listed can help

from gatsby-docker.

gatsbot avatar gatsbot commented on June 12, 2024

@NogaMan We noticed that the body of this issue is blank.

Please fill in this field with more information to help the maintainers resolve your issue.

Generated by 🚫 dangerJS

from gatsby-docker.

shicholas avatar shicholas commented on June 12, 2024

Did you run yarn build before docker build ?

from gatsby-docker.

dimiandre avatar dimiandre commented on June 12, 2024

I have the exact same problem.
Already did npm run build

info Done building in 14.082574965 sec
MacBook-Pro-3:fronted dimiandre$ docker build -t telepsycovid/frontend .
Sending build context to Docker daemon  2.417MB
Step 1/3 : FROM gatsbyjs/gatsby:onbuild as build
# Executing 1 build trigger
ADD failed: stat /var/lib/docker/tmp/docker-builder048987704/public: no such file or directory```

from gatsby-docker.

IgordeOliveira avatar IgordeOliveira commented on June 12, 2024

Do check the .dockerignore file too.

from gatsby-docker.

KevinBurton avatar KevinBurton commented on June 12, 2024

I also have this issue.

from gatsby-docker.

KevinBurton avatar KevinBurton commented on June 12, 2024

I solved the problem by doing a custom Dockerfile based on nginx image.
My Dockerfile and my nginx config are in this public gist https://gist.github.com/NogaMan/3ae6bd88e8ae063ab6da56bc36659c7d

The files are working 100%

Whn I try this I get

Step 9/9 : COPY docker/vhost.conf /etc/nginx/conf.d/default.conf
COPY failed: stat /var/lib/docker/tmp/docker-builder704808398/docker/vhost.conf: no such file or directory
error Command failed with exit code 1.

Earlier in the build I do get
warning [email protected]: Invalid bin field for "url-loader".

from gatsby-docker.

airtonix avatar airtonix commented on June 12, 2024

why are you using gatsby outside of the container? i'm so confuse.

I would have thougt this defeats the whole point of docker.

from gatsby-docker.

gardner avatar gardner commented on June 12, 2024

@airtonix the use case is to develop locally using the docker container and then deploy the code to production using the docker container. This is a selling point of docker and a common use case. It allows the developer to use specific versions of dependencies on the dev machine that may be incompatible with other projects they are working on.

from gatsby-docker.

zurheide avatar zurheide commented on June 12, 2024

Any news about fixing this bug?

https://stackoverflow.com/questions/51421666/nginx-server-not-running-with-gatsbyjs-default-docker-image

And check the .dockerignore for the public folder. Worked for me then with this description.

from gatsby-docker.

doman18 avatar doman18 commented on June 12, 2024

Any news about fixing this bug?

https://stackoverflow.com/questions/51421666/nginx-server-not-running-with-gatsbyjs-default-docker-image

And check the .dockerignore for the public folder. Worked for me then with this description.

Yes it will works for local development but not for the CI/CD environments where you dont have npm installed on the docker hosts.

from gatsby-docker.

Related Issues (20)

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.