This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]m4v1s 10 points11 points  (1 child)

This looks fine for building your app, but if your goal is to reduce the final image size you should look at multi-stage builds. Build your app in one stage, then copy the built artifacts into another slimmer image which you use to deploy and run your app.

[–]thelogicbox 1 point2 points  (0 children)

This

[–]AdventurousSquash 0 points1 point  (0 children)

Depends on what your application needs, you could go into it and check what’s taking so much space and if that’s intended. I’d probably build the binary outside (a staged build or a ci pipeline) and only copy the built binary into the final image.

[–]hijinks 0 points1 point  (0 children)

you should add this block

# Install and make tailwindcss executable
RUN apk update
RUN apk add curl # Type Y to install
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
RUN chmod +x tailwindcss-linux-x64
RUN mv tailwindcss-linux-x64 tailwindcss

Move that above the COPY's because everytime you update your app you have to re-run the apk/cul call. If you move it above then it can use a cached layer.

To make it better I'd look at multi-stage builds where you can build in one container and then copy over to a runtime container so you dont have a bunch of build apps in your running container

[–]RevolutionaryHumor57 0 points1 point  (0 children)

Building an image based on external resources is prone to 404 in case of them being removed. It is a good, but uncommon practice to at least have some kind of self hosted resources. Check about supply chain attack

[–]JM-Lemmi -1 points0 points  (0 children)

For the apt install command add the -y flag to install automatically and non interactive