A total Docker newbie here.
I have a web application that uses two repositories. One of the repositories is basically a 'client' app, while the second one is the server. The server serves the static files from the client app.
I would like to dockerize the whole thing. In order to do so, now I'm wondering what is the best practice for this:
- pull the client and build it inside the image
- do the rest
Or
- pull the client code in an external bash script
- somehow copy the build files to the image
- do the rest
Or
- pull the client code in an external bash script
- never put the client code in the image, use it externally somehow
- do the rest
The first approach is working actually, but it seems wasteful since the image is now very big and contains disposal files.
The second approach feels "better" but when I run docker-compose up from the bash script I can't copy the files already, since the script is already running:
#!/bin/bash
git clone ... ~/tmp/client
(cd ~/tmp/client && yarn && yarn build && mv build ~/tmp/build)
docker-compose up
rm -rf ~/tmp/client
As for the third approach I don't even know how to do that.
Any suggestion or reference would be very helpful.