Am I supposed to be able to do the equivalent of docker-compose up without detached and declare a service that streams until I "ctrl+c" to exit?
Experimenting with service binding for serving mkdocs locally and not sure if that's an unsupposed use case.
#Serve and wait for exit
1 messages · Page 1 of 1 (latest)
You don't need to worry about Start() and Stop() fwiw
With service bindings, the engine will figure out when to start and stop on its own
Start() is kind of like Sync(), it's only for the very rare situation where you want to force starting the service at a specific time. But 99% of the time you don't have to worry about that. Same for Stop()
So give your MkDocsServe() function, you can call it from the CLI with dagger call mk-docs-serve as-service up, which will:
- Call your function to get the container
- Convert that container to a service
- Call
upon that service which runs it and forwards its ports to the client machine
k i'll play with this. thank you for the help!
You can also have a function that returns a Service directly
any work in progress for interactive task selection btw? Dagger is great, but these commands are pretty wordy so thinking about easier invoking for folks like how I have mage compose:up. or mages and get the UI to select. Not critical, just got me curious.
This is even better. I need to figure out how to build base image, return service from that and will try out all you mentioned. 🙏
Re: end-user convenience. Some issues to watch:
got it working!
Now I need one other thing and I think I'm good on the initial example for team.
- I return a container from one function, define a service from this in another.
- The container has looped pip install.
- I tried referencing the local image build like
dev.local/mkdocs-localbut it doesn't know about this image. - is there anyway I can get it to use my container image defined but if it's already built not rerun the looped exec install statements?
Essentially I rebuilt withexec the following
# Build: docker build -t dev.local/mkdoc:latest -f docker/Dockerfile.mkdocs .
# docker run --rm -it -p 8000:8000 -v ${PWD}:/docs dev.local/mkdoc:latest serve --clean --dev-addr 0.0.0.0:8000
FROM squidfunk/mkdocs-material:latest
# FROM dev.local/mkdocs-material:latest
COPY . /docs
# optimize caching by freezing the requirements in image if possible
RUN if [ -f /tmp/requirements.txt ]; then \
python3 -m pip install -r /tmp/requirements.txt ; \
else \
python3 -m pip install \
mkdocs-glightbox \
mkdocs-rss-plugin \
mkdocs-autolinks-plugin \
mkdocs-git-revision-date-localized-plugin \
mkdocs-exclude \
mkdocs-git-authors-plugin \
mkdocs-swagger-ui-tag \
mkdocs-glightbox \
markdown-callouts \
mkdocs-awesome-pages-plugin ; \
fi
ENTRYPOINT [ "mkdocs" ]
So I don't want those looped pip installs you saw in the freeze requirements thread to be rerun on everytime I run service up basically.
Any tip?
@errant current sorry I don't understand where you're stuck. You're trying to reproduce the behavior of this Dockerfile, in Dagger?