gitignore.io icon indicating copy to clipboard operation
gitignore.io copied to clipboard

chore(docker): Optimize dockerfile

Open mritd opened this issue 2 years ago • 10 comments

Optimize dockerfile

Signed-off-by: kovacs [email protected]

mritd avatar May 22 '22 07:05 mritd

@filipechagas Can we use swift:5.6-focal?

image

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.

mritd avatar Jun 16 '22 05:06 mritd

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 .

image

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.

mritd avatar Jun 16 '22 09:06 mritd

@filipechagas I re-edited the CMD command and added some comments so anyone can build their own docker image.

mritd avatar Jun 17 '22 03:06 mritd

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

mritd avatar Jun 20 '22 04:06 mritd

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?

filipechagas avatar Jul 13 '22 15:07 filipechagas

I think it's ok, do I need to undo the changes to Dockerfile.dev and docker-compose-dev.yaml?

mritd avatar Jul 14 '22 03:07 mritd

Can you please? That way we avoid misleading people into thinking they're finished.

filipechagas avatar Jul 14 '22 11:07 filipechagas

I have rolled back the changes to dev.

mritd avatar Jul 20 '22 03:07 mritd

This PR is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 20 '22 02:08 github-actions[bot]

@filipechagas

mritd avatar Aug 20 '22 13:08 mritd

No response for too long, I close this PR.

mritd avatar Dec 11 '22 11:12 mritd

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

konstrybakov avatar Dec 12 '22 06:12 konstrybakov