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

Optimize docker container usage #1704

Merged
merged 6 commits into from
Nov 16, 2023

Conversation

ngehrsitz
Copy link
Contributor

Currently the docker container has to be invoked with

docker run --rm -v $(pwd):/code -w /code ghcr.io/swaggo/swag:v1.16.2 /root/swag

which means users have to know that the binary is placed under /root/swag. If they don´t know this and just try

docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:v1.16.2

they will get the error

docker: Error response from daemon: No command specified.

if they then try

docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:v1.16.2 swag

it won´t work either

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "swago": executable file not found in $PATH
: unknown.

This PR adds an ENTRYPOINT meaning the first command will just work. It also moves the binary to /bin since having the binary in the same directory as the default WORKDIR is suboptimal since users need to mount their code into the container. If the binary is not stored in the WORKDIR, then users can simply mount their code to that directory without having to specify a different one with -w.

@ubogdan
Copy link
Contributor

ubogdan commented Nov 15, 2023

Would you mind adding some docker usage tips in the Readme.md?

@ngehrsitz
Copy link
Contributor Author

Would you mind adding some docker usage tips in the Readme.md?

Did you notice the section I added there? I am not sure what else would be relevant?

@ubogdan ubogdan merged commit 0ade78c into swaggo:master Nov 16, 2023
10 checks passed
@ubogdan
Copy link
Contributor

ubogdan commented Nov 16, 2023

@ngehrsitz Thanks for your contribution!

@ngehrsitz ngehrsitz deleted the container-with-entrypoint branch November 16, 2023 11:58
@ngehrsitz
Copy link
Contributor Author

@ubogdan Please create a new release, so that ghcr.io/swaggo/swag:latest will actually work as described.

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

Successfully merging this pull request may close these issues.

None yet

2 participants