How can I break out of this Docker feedback loop?

0
6
Asked By CuriousCoder42 On

I'm working on a project that uses Vue.js, Python, and Postgres. After I created a minimum viable product (MVP), I decided to host it on Google Cloud for continuous access to learn about the development-to-production workflow. However, my VM is on the cheaper end with just 2GB of RAM and one CPU core, which is enough for the application to run, but not for building Docker images using Docker Compose.

To get around this, I thought about using Docker Hub's private repository. My plan was to build the images locally with the production environment files and Dockerfiles, push the images to Docker Hub, pull them onto my VM, and then run the images from there.

While testing, I removed some components from the Vue.js application to see if the changes would reflect in the live site. After building the image, pushing it to Docker Hub, and pulling it into the VM, the expected changes were not showing up on the website. Instead, I found that I had to perform a `git pull` to see those changes reflected. Why is that happening?

3 Answers

Answered By CodeNinja On

Another tip: instead of building images on your 2GB VM, check out CI/CD services like GitHub Actions or GitLab CI. They can build your Docker images during the workflow and push them to Docker Hub. This means that your VM only needs to pull the latest images and start them, making the process smoother.

CuriousCoder42 -

That sounds like it could save me a lot of headaches! Thanks for the advice!

Answered By DevWhiz99 On

It sounds like you might be using bind mounts in Docker. When you bind mount, the files on your host can override the files in your container. That’s why your changes only show after a `git pull` because the container's files are being replaced by the files from your VM.

TechSavvyJoe -

Exactly! Just make sure your Vue, Python, and Postgres services are separate. You could use Docker Compose to manage multiple containers. Keep your database persistent with a volume for Postgres, but you don’t really need to bind mount for Vue unless you're developing directly.

Answered By DockerDude On

You might also want to try a multi-stage build for your Vue app. Build the static files in one Docker stage and then copy them to an Nginx container. This way, you won’t need bind mounts at all, making your final image smaller and easier to manage.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.