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 volume path can't be served as static app #113

Open
zdllucky opened this issue Apr 20, 2021 · 1 comment
Open

Docker volume path can't be served as static app #113

zdllucky opened this issue Apr 20, 2021 · 1 comment

Comments

@zdllucky
Copy link

zdllucky commented Apr 20, 2021

Bug report

Docker volume path can't be served as static app.

Firstly thanks to maintainer folks for such a cool headless (Best one i ve used so on). Here is what I got

Describe the bug

I am trying to conteierize my app within docker and also do serve some uploads, so in order to prevent upload file loss ive decided to store those in separate docker volume. The error says it cant find the volume path
A clear and concise description of the bug.

Like this
My Static app configuration

new StaticApp(
	{
		path: '/uploads/',
		src: process.env.NODE_ENV === 'production' ? `/media/uploads/` : `uploads/`,
		fallback: '/'
	}
)

When I run docker I also specify my volume (-v /a:/b) and it works fine. But i get this error during docker build:

- Initialising Keystone CLI
ℹ Command: keystone build
-  
✔ Validated project entry file ./index.js
- Initialising Keystone instance
✔ Initialised Keystone instance
- Exporting Keystone build to ./dist
✖ Exporting Keystone build to ./dist
[Error: ENOENT: no such file or directory, stat '/media/uploads'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/media/uploads'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error response from daemon: The command '/bin/sh -c yarn install && yarn migrate && export COOKIE_SECRET=$(openssl rand -hex 32) && yarn build && yarn cache clean' returned a non-zero code: 1
Failed to deploy 'daiana_dev Dockerfile: ./docker/Dockerfile':

To Reproduce

I hope the reproduce process is qiute clean from above. Just try to add volume path as static app path

Expected behaviour

I understand that it might occur during build time when volume is still not inited but asking this kind requirement during buildtime (not launch time) seems quite irrational
I actually hoped it will host static app from any runtime real location specified.

System information

  • OS: macOS BigSur
  • Docker any
  • Browser any
@zdllucky
Copy link
Author

Btw, the native express serve static works fine^ that is why I proposed bad behaviour of StaticApp

configureExpress: app => {
  app.set('trust proxy', 1);
  app.use('/uploads',
    static(process.env.NODE_ENV === 'production'
      ? `/media/uploads/`
      : `static/uploads/`, options));
}

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

No branches or pull requests

2 participants