Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
Docker workflow for automated builds on Github-Dockerhub

I already have set up a github repository with 3 branches (master, dev and docker). I already set up successfully and linked the automated build on dockerhub. Each time a push is done on Github an image is built on Dockerhub with different tag (latest for master, beta for dev and alpha for docker). This is working fine. Now the problem...

On Dockerfile, there is a git clone command to retrieve the project. The problem is this is pointing to master always. So if I push something to docker branch for example (it builds image with alpha tag) the code of project on that image is the code of master and not code of branch docker which is the desired for this case.

If I modify the Dockerfile of branch docker (which generate alpha tagged image) and I put git clone -b docker ... the build is ok, but after all the tests, when I want to merge with a pull request from docker branch to dev branch for example, another updated is needed on dev to change the git clone command inside of Dockerfile to point to the right branch. And the same with a pull request from dev to master with the additional difficult of on this project the master branch is protected and I can't push directly to master... so after a pull request from dev to master I can't fix Dockerfile changing the Dockerfile to change git clone to point again to master.

Is there a way to have different branches with different tags on automated building without changing anything after pull requests from one to other branch? Thank you.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

When using automated builds, this is what happens;

  • Docker Hub (or Docker Cloud, which has some more advanced features) checks out the git commit that triggered the build
  • It builds the Dockerfile that you configured to build from in your automated build

From the above; you should not git clone inside your Dockerfile at all, because you'd be doing what's already done by the automated build. Simply do;

FROM some-base-image

# Copy your project's source into the image
COPY . /my-src
RUN do-something-with-the-source

Docker Cloud has advanced features, which allow you to run custom scripts at various stages of the automated build, using build phase hooks (documentation). This allows you (for example) to make "minimal" images by building your project in a "build image", then copying the generated code to a local directory, and building the final image from that.

edit

The Automatic build options on Docker Cloud has more features than Automatic Build on Docker Hub. For example, the Dockerfile to build, and the build-context can be set separately. This allows you to have a Dockerfile in a subdirectory, but use files outside of that subdirectory to be used as the build context. To do this, set the Dockerfile location to (e.g.) /docker/Dockerfile, and the buildcontext to /

enter image description here

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda