-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Compose hosted returns 404 for all images #380
Comments
The Traefik Instructions don't mention that bypassing the caddy service in the container prevents access to A labels:
- traefik.enable=true
- traefik.docker.network=proxy
- traefik.constraint-label=traefik-public
#----------------------------------------------- routers for: postiz --------------------------------------------------
# HTTP router
- traefik.http.routers.postiz-${SITE}-http.rule=Host(`${SITE_DOMAIN}`)
- traefik.http.routers.postiz-${SITE}-http.entrypoints=http
- traefik.http.routers.postiz-${SITE}-http.middlewares=servicests,block-apple,https-redirect,reporturi
- traefik.http.routers.postiz-${SITE}-http.service=noop@internal
# HTTPS router for uploads
- traefik.http.routers.postiz-uploads-${SITE}-https.rule=Host(`${SITE_DOMAIN}`) && PathPrefix(`/uploads/`)
- traefik.http.routers.postiz-uploads-${SITE}-https.entrypoints=http3
- traefik.http.routers.postiz-uploads-${SITE}-https.service=postiz-uploads-${SITE}
- traefik.http.routers.postiz-uploads-${SITE}-https.tls.certresolver=${SITE_RESOLVER}
- traefik.http.routers.postiz-uploads-${SITE}-https.middlewares=gzip,limit,reporturi,block-apple
- traefik.http.routers.postiz-uploads-${SITE}-https.priority=20
# HTTPS router for frontend
- traefik.http.routers.postiz-${SITE}-https.rule=Host(`${SITE_DOMAIN}`) && !PathPrefix(`/uploads/`)
- traefik.http.routers.postiz-${SITE}-https.entrypoints=http3
- traefik.http.routers.postiz-${SITE}-https.service=postiz-${SITE}
- traefik.http.routers.postiz-${SITE}-https.tls.certresolver=${SITE_RESOLVER}
- traefik.http.routers.postiz-${SITE}-https.middlewares=gzip,limit,reporturi,block-apple
- traefik.http.routers.postiz-${SITE}-https.priority=10
# HTTPS API router
- traefik.http.routers.postiz-api-${SITE}-https.rule=Host(`api.${SITE_DOMAIN}`)
- traefik.http.routers.postiz-api-${SITE}-https.entrypoints=http3
- traefik.http.routers.postiz-api-${SITE}-https.service=postiz-api-${SITE}
- traefik.http.routers.postiz-api-${SITE}-https.tls.certresolver=${SITE_RESOLVER}
- traefik.http.routers.postiz-api-${SITE}-https.middlewares=cors-headers-${SITE},gzip,limit,reporturi,block-apple
#----------------------------------------------- CORS Middleware --------------------------------------------------
# Define CORS headers middleware
- traefik.http.middlewares.cors-headers-${SITE}.headers.accessControlAllowOriginList=https://${SITE_DOMAIN}
- traefik.http.middlewares.cors-headers-${SITE}.headers.accessControlAllowMethods=GET,OPTIONS,PUT,POST,DELETE
- traefik.http.middlewares.cors-headers-${SITE}.headers.accessControlAllowHeaders=Origin,Content-Type,Accept,Authorization
- traefik.http.middlewares.cors-headers-${SITE}.headers.accessControlAllowCredentials=true
- traefik.http.middlewares.cors-headers-${SITE}.headers.addVaryHeader=true
#====================================================== services ===========================================================
- traefik.http.services.postiz-${SITE}.loadbalancer.server.port=4200
- traefik.http.services.postiz-api-${SITE}.loadbalancer.server.port=3000
- traefik.http.services.postiz-uploads-${SITE}.loadbalancer.server.port=5000 |
Heya @troykelly , you're using the wrong syntax to specify environment variables in your docker-compose, you're using an = sign in your pasted examples, but the syntax is to use a : indocker-compose. Not this - STORAGE_PROVIDER=local Do this instead - STORAGE_PROVIDER: local You will need to |
@jamesread No? I'm using mapping syntax. https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/#use-the-environment-attribute If you want to use a colon you don't use the hyphen: services:
webapp:
environment:
DEBUG: "true" |
Just to clarify - the issue doesn't appear to be the settings. It's that the Because there is a conflict in the documentation - I'm just setting both |
I can confirm, this applies to all docker compose deployments, and the documentation is not clear that you MUST only point to port 5000 for the uploads to work. |
I ended up doing the split pointing because when I only used 5000 nothing would work. It might be better to have an "entry level" one container to rule them all (as is mostly the case now) and a set of containers for frontend, backend, static/uploads file service. -given it's generally best practice for a container to do one thing - not all the things. |
Hey @troykelly, Sorry that it's taken me a little while to get back to you.
I'm sorry, I was wrong, you are absolutely right. I'm just so used to seeing the YAML map syntax that = syntax looks wrong to me. You're right, it's not the cause of the problem here.
I've just adjusted the diagram to include this; Equally, the Traefik docs were written before the introduction of the Caddy internal proxy (because we wanted to do stuff like host /uploads), and get around loads of CORs issues. @troykelly @MikeKMiller Would you mind looking at teh adjusted docs for Traefik, and check that it reads a little more sane now?
Of course you should be able to still do this split configuration (4200, 3000, etc), but generally we have been trying to make it easier on everyone by just having one port - 5000, and we've seen the support tickets on this area massively decrease. If you have a working setup, great, but also consider if you'd like you should be able to simplify by just using port 5000.
It is possible to just start up single services within the same container image - http://localhost:3000/installation/docker-compose#controlling-container-services - however this approach just means Postiz uses more RAM / CPU / Storage without being any more stable. We don't want to build more container images, as it doesn't really solve any problems anyone has right now. Keen to know if the docs are now better for you, keen to take your suggestions and comments until they're improved! |
@jamesread I did originally try just to port My apologies for missing https://docs.postiz.com/installation/docker-compose#controlling-container-services. Thank you. I will update our configuration accordingly to separate things. I typically try to keep to one container, one service:
I completely understand the desire to optimize resource usage, especially when deploying to environments with limited resources. I'd be happy to discuss this further or help with any adjustments if you're interested. Perhaps two examples with shared services and single-purpose containers? Again, thank you for your amazing work on Postiz! |
Hey @troykelly
Great, and thanks for your patience :-) Sorry for misreading your last post so badly!
I don't necessarily disagree with anything you've written there - I personally run Kubernetes for most of my stuff at home (although my personal Postiz instance actually does run on a docker VM), but just saying that I understand service isolation and those concepts, etc. We're seeing that the vast majority of users picking up Postiz are running on their laptops, or are non-technical folks, so if we did do something in addition to the "monolithic" container image we'd have to display it or make it available separately so we're not confusing anybody. At this moment this project literally has SO many new users coming in that it's difficult to keep up with support tickets as it is! Adding more installation options comes at the cost of a higher support overhead too - so we'd need to be clear that this is something a bunch of people want. Inside the existing "monolithic" container, there is a supervisord, so you do have at least a level of control over starting/stopping services. It's not the same as individual container controls, but it's something. I'm hoping that setting POSTIZ_APPs="worker", etc works for you for the time being - but come back if this approach has downsides? Do you think it's OK to close this issue? |
All great @jamesread - thank you! |
📜 Description
When trying to use postiz in a compose hosted environment - all images return 404.
I've tried setting the environment variable
NEXT_PUBLIC_UPLOAD_DIRECTORY
per https://docs.postiz.com/installation/docker-composeI've tried setting the environment variable
NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY
per https://github.com/gitroomhq/postiz-app/blob/main/.env.exampleDoes not work
Does not work
👟 Reproduction steps
👍 Expected behavior
It should work
👎 Actual Behavior with Screenshots
Container Log
Files are there
💻 Operating system
Linux
🤖 Node Version
v20.17.0
📃 Provide any additional context for the Bug.
Compose
👀 Have you spent some time to check if this bug has been raised before?
Are you willing to submit PR?
Yes I am willing to submit a PR!
The text was updated successfully, but these errors were encountered: