Closed JacobAMason closed 6 years ago
If we're going to do Docker, I'd rather do a more minimal image that pulls in luarocks and does an install with that. Xenial is needlessly heavy.
The Xenial Docker image is pretty small (111Mb). The dependencies themselves are what's taking up most of the space. I picked Ubuntu as the base because of a warning I read here that said Ubuntu was already tested. I can try to make this a multistage build and lose some of the build-time dependencies.
I may try my hand at this in around an hour with a more minimal image if you want to give multi-stage a shot.
New image size is 124M
Aaaand that's pretty much what I was going to try for. Can't think of what I'd add besides making luarocks build-time dependencies (e.g. GCC) be uninstalled when done and using --no-cache add
, as documented here.
Ha, I thought about doing that so I guess I will. Thanks for the link
Saved a whole megabyte, lel
Only a single MB? That's disappointing. Going to bed for now, but I'll try out some more hard stuff tomorrow. This feels like it should be able to get a lot smaller. Aside from the concerns about package deletion, this looks like a solid Alpine image though.
Ehh, those development libraries are probably just small header files. I think the rest of the space is in whatever rocks are installed--and I know nothing about lua, so I'm no help there, sorry.
Sorry, one last thing: could you combine the run commands into one chain? After that, LGTM.
Ahh, that was the key to making it smaller: only 8.13MB now. I guess Docker saves those intermediate stages in the final image? Hum.
Cool. Could you use apk --no-cache add --virtual build-deps … && … && apk del build-deps
and squash your commits? (There's not much point to having each of these steps in the final history.)
Whenever you merge in GitHub, it will give you the option to squash and merge, that way you can name the merge whatever you want.
Sorry, forgot that was a new feature.
Woot. Thanks
I added a small Dockerfile that will grab the necessary dependencies to run the bot. I also turned the api key and admin id in config.lua into environment variables so they could be passed into the docker container at startup.
Example:
docker run -e OTOUTO_BOT_API_KEY="apikeyhere" -e ADMIN_ID="idhere" jacobamason/otouto