gitignore.io
gitignore.io copied to clipboard
chore(docker): Optimize dockerfile
@filipechagas Can we use swift:5.6-focal
?

I noticed that it supports both x86 and arm64; this way x86 and arm64 users can not care about the image architecture, and we can also build images with multi-arch support.
I've modified the Dockerfile so that it now supports both x86 and arm64 builds (due to the swift image not supporting other CPU architectures for now).
It is now possible to use the docker buildx
command to build a multi-CPU architecture-supported image (compatible with the standard docker build
command), I have pre-built a version: mritd/gitignore.io
, this image can be used to verify this PR .

By the way, I'm not familiar with the swift language, and I don't know if there are other compilation parameters that can optimize the size of the binary compiled by swift; if there are better compilation parameters, I can further optimize the image size.
@filipechagas I re-edited the CMD command and added some comments so anyone can build their own docker image.
I noticed that there is a compose configuration created for development; I created a Dcokerfile (Dockerfile.dev) dedicated to development, but the vapor command fails to execute.
Since I'm not a swift developer, I don't know how to fix the vapor compilation problem (maybe I should downgrade the vapor toolbox version?), @filipechagas can you pass some sample commands to run the project via vapor run
and some related version information?
This way I can recreate the dockerfile and compose files for development; I think the development environment should meet the following requirements:
- Map the current directory into the container to ensure native code runs
- Recompile swift code every time to ensure consistency
- Cache swift packages as much as possible to avoid repeated downloads
Sorry about the delay on this one. I was OOO.
I just realized that docker-compose for development wasn't really working already. So, at this point, I would apply your excellent changes in the Dockerfile
. We can ditch Dockerfie.dev
for now and work on that in a separate PR.
WDYT?
I think it's ok, do I need to undo the changes to Dockerfile.dev and docker-compose-dev.yaml?
Can you please? That way we avoid misleading people into thinking they're finished.
I have rolled back the changes to dev.
This PR is stale because it has been open for 30 days with no activity.
@filipechagas
No response for too long, I close this PR.
Hey @mritd, very sorry for the long review! Is this still something you'd like to be merged? I'll have a quick look and move this forward