Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Build Error ARG or ENV missing during build process NEXT_PUBLIC_SALEOR_API_URL #1067

Open
jdmueller opened this issue Jan 11, 2024 · 3 comments

Comments

@jdmueller
Copy link

Summary

I have followed the directions: cloned the repo, cp .env.example to .env, I have run pnpm i. When I create a docker image of this repo it fails with the same reason/text/error above from original poster. I saw also that the .env file was being ignored by the .gitignore file and even changing this does not fix it. It has been 3 years since I worked with a saleor store and I am not sure what I could be doing wrong since the directions seem simple enough to follow. I have used this process for Saleor and Dashboard and they create the docker images without any errors.

2024-01-10T16:04:12Z > [builder 6/6] RUN pnpm build:
2024-01-10T16:04:12Z #22 1.681 > pnpm run generate
2024-01-10T16:04:12Z #22 1.681
2024-01-10T16:04:12Z #22 2.895
2024-01-10T16:04:12Z #22 2.895 > saleor-storefront@0.1.0 generate /app
2024-01-10T16:04:12Z #22 2.895 > graphql-codegen --config .graphqlrc.ts
2024-01-10T16:04:12Z #22 2.895
2024-01-10T16:04:12Z #22 5.155 Before GraphQL types can be generated, you need to set NEXT_PUBLIC_SALEOR_API_URL environment variable.
2024-01-10T16:04:12Z #22 5.157 Follow development instructions in the README.md file.
2024-01-10T16:04:12Z #22 5.223  ELIFECYCLE  Command failed with exit code 1.
2024-01-10T16:04:12Z #22 5.246  ELIFECYCLE  Command failed with exit code 1.
2024-01-10T16:04:12Z ------
2024-01-10T16:04:12Z ERROR: failed to solve: executor failed running [/bin/sh -c pnpm build]: exit code: 1
2024-01-10T16:04:12Z Build failed using Buildkit (1)

I have this being built within the hub.docker system straight from my GitHub repo.

Screenshot 2024-01-10 at 5 12 37 PM I have even specified these in the build variables section of the hub.docker system and the build still fails. I don't understand why the other 2 images (Saleor 3.18 and Dashboard 3.18) will build correctly but this one does not.

This repo will however work if I use 'docker compose up' from my local computer m2 Mac.

Steps to reproduce

  1. Clone repo
  2. cp .env.example to .env file and configure settings
  3. run ppm i
  4. add image to hub.docker.com and set as automatic build from GitHub repo
  5. add build arguments into section for NEXT_PUBLIC_SALEOR_API_URL and NEXT_PUBLIC_STOREFRONT_URL
  6. Build process fails with error:

2024-01-10T23:53:14Z > [builder 6/6] RUN pnpm build:
2024-01-10T23:53:14Z #22 1.761 > pnpm run generate
2024-01-10T23:53:14Z #22 1.761
2024-01-10T23:53:14Z #22 2.992
2024-01-10T23:53:14Z #22 2.992 > saleor-storefront@0.1.0 generate /app
2024-01-10T23:53:14Z #22 2.992 > graphql-codegen --config .graphqlrc.ts
2024-01-10T23:53:14Z #22 2.992
2024-01-10T23:53:14Z #22 5.275 Before GraphQL types can be generated, you need to set NEXT_PUBLIC_SALEOR_API_URL environment variable.
2024-01-10T23:53:14Z #22 5.277 Follow development instructions in the README.md file.
2024-01-10T23:53:14Z #22 5.343  ELIFECYCLE  Command failed with exit code 1.
2024-01-10T23:53:14Z #22 5.370  ELIFECYCLE  Command failed with exit code 1.
2024-01-10T23:53:14Z ------
2024-01-10T23:53:14Z ERROR: failed to solve: executor failed running [/bin/sh -c pnpm build]: exit code: 1
2024-01-10T23:53:14Z Build failed using Buildkit (1)

A link to a reproduction repository

https://github.com/jdmueller/AdventureStorefront

Output from envinfo

No response

@jdmueller
Copy link
Author

jdmueller commented Jan 13, 2024

I have also tried to build this on my local Mac mini M2 and the build command will not run getting the same error as hub.docker.com even with the env variable set before running. It will work however if I run 'docker compose up' command.

export NEXT_PUBLIC_SALEOR_API_URL=http://localhost:8000/graphql/

=> ERROR [builder 6/6] RUN pnpm build 1.5s

[builder 6/6] RUN pnpm build:
0.475
0.475 > saleor-storefront@0.1.0 prebuild /app
0.475 > pnpm run generate
0.475
0.742
0.742 > saleor-storefront@0.1.0 generate /app
0.742 > graphql-codegen --config .graphqlrc.ts
0.742
1.496 Before GraphQL types can be generated, you need to set NEXT_PUBLIC_SALEOR_API_URL environment variable.
1.496 Follow development instructions in the README.md file.
1.503  ELIFECYCLE  Command failed with exit code 1.
1.512  ELIFECYCLE  Command failed with exit code 1.


Dockerfile:37

35 | RUN yarn global add pnpm@$PNPM_VERSION
36 |
37 | >>> RUN pnpm build
38 |
39 | # Production image, copy all the files and run next

ERROR: failed to solve: process "/bin/sh -c pnpm build" did not complete successfully: exit code: 1

@jdmueller jdmueller changed the title Build error in hub.docker.com for arg or env missing during build process Build error for arg or env missing during build process NEXT_PUBLIC_SALEOR_API_URL Jan 13, 2024
@jdmueller jdmueller changed the title Build error for arg or env missing during build process NEXT_PUBLIC_SALEOR_API_URL Docker Build Error ARG or ENV missing during build process NEXT_PUBLIC_SALEOR_API_URL Jan 13, 2024
@tgrycuk
Copy link

tgrycuk commented Jan 24, 2024

I've submitted a pull request (#1069) that addresses the issue reported. This pull request aims to resolve the problem related to building the Docker image using Docker Compose.

These simple steps are enough to run the application in the basic version:
git clone https://github.com/saleor/storefront.git .
cp .env.example .env
docker-compose build
docker-compose up

@tgrycuk
Copy link

tgrycuk commented Jan 24, 2024

Let me know what stage you are at.
If you still have a problem with this, it seems to me that the machine you are building it on may not have enough free resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants