0

A few years ago, I wrote a simple web application in PHP without a database. Until now, it was running on a basic Apache server. I'm not a professional developer; I'm more on the system side.

I haven't had the chance to work on contracts with DevOps infrastructures yet. To better understand containers' operation and benefits, I tried to replicate an infrastructure (very simplified version) as if I were in a company, and this application had to go through development, testing, and production stages. I rented a CentOS VPS for the production environment, a Debian VPS for the testing environment, and used my personal Windows PC as the development environment. In the diagram below, I also added another development environment as if another developer were working on the project. I connected all of this to Github and Docker Hub.

I have a question regarding image creation. Once I've developed my code and tested it locally with an apache php docker container, I create a Docker image with the code embedded in it. I create this image using a Dockerfile on my development machine. I push this image to Docker Hub and use it for the testing and production environments.

In real life, I doubt that the image is created from the development machines. So, where should it be created from?

Any guidance or thoughts would be much appreciated. This is new territory for me.

Note: I do have proxies and multiple sites on servers but I removed them from the diagram to simplified the question.

enter image description here

7
  • 2
    reddit.com/r/ProgrammerHumor/comments/cw58z7/…
    – Doc Brown
    Commented Oct 27, 2023 at 22:01
  • 1
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Oct 28, 2023 at 2:58
  • 2
    You're massively overcomplicating things, but the absence of CI/CD is notable. It would be common to have an automated pipeline that builds, tests, and deploys your project whenever you push to your repository. Another detail is the absence of a reverse proxy service. Not needed, but would allow you to host multiple sites on one server, for example both dev and prod. Such reverse proxies would typically also manage TLS termination.
    – amon
    Commented Oct 28, 2023 at 6:06
  • Thanks so much @amon. As you were answering, I was editing the question to try to be more specific. I do have proxies services on testing and production servers and host several sites. I just removed them from my diagram to make things simplified for the question. :) Commented Oct 28, 2023 at 6:17
  • @amon, can you tell me more about 'massively overcomplicating' please? For example, what could be simplified? Commented Oct 28, 2023 at 6:35

1 Answer 1

2
In real life, I doubt that the image is created from the development machines. So, where should it be created from?

Usually you would do your build process on a build machine. I guess coming from PHP you don't really "build", but running your docker files, db setup scripts would count as "building"

You say you use github, which has "runners" and "actions" for this kind of thing

https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners

I've not used github actions myself, but i imagine you can setup a whole pipeline of actions to automate what you currently do manually on your dev machine, so that new builds are automatically pushed to your test or dev environment and tested builds can be automatically deployed to your live env

2
  • Thanks @Ewan. Do you think I should have another server between dev environments and test environment just to execute dockerfile that package my code into a docker image? Commented Oct 28, 2023 at 13:30
  • 1
    yes, but if you use github it can do it for you
    – Ewan
    Commented Oct 29, 2023 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.