Deploying using Dockerfile target

Hi,

I would like to know if it’s possible to specify a Dockerfile target for deployment ?

Thanks a lot

Hi @Orkin , what do you mean by a Dockerfile target? Do you mean that you want to use a Dockerfile to deploy your application? In this case, yes, it’s possible, even the default option with Qovery. You can take a look at this documentation.

Hi @rophilogene I’m mean when using docker file like this

FROM php:8.0-apache-buster as apache_php

...

FROM apache_php AS apache_php_dev

... or ...
FROM XXX as redis

With docker-compose you can choose the target : apache_php for docker-compose global and for dev or in docker-compose override change the target by apache_php_dev. You can use 1 Dockerfile to for many containers

When using Qovery only the last FROM instruction is used and I didn’t find how to specify I would like to use apache_php as target and not apache_php_dev with that I can use only 1 Dockerfile for the project

Indeed, with Qovery, you can have multiple Dockerfile and specify the one that you want to use. Can you tell me more about your use case of using one Dockerfile and specify the target?

Because many project like Symfony provide an official support of docker with a Dockerfile that you can find here (for example) : GitHub - dunglas/symfony-docker: A Docker-based installer and runtime for Symfony. Install: download and `docker compose up`. . This Dockerfile is optimised for production and development purpose using target. There is not specific use case it’s juste QOL feature to support target in Dockerfile in this case no more work is needed to use Qovery

bumping this, this is the current recommended way to handle Dockerfiles to minimize size / build time and the fact that it isn’t supported is pretty disappointing.

Hi @macwilk you can do it by building by yourself your container and using Qovery CLI with container application. You can find documentation here : Application | Docs | Qovery and here How to integrate Qovery with GitHub Actions | Qovery

If your application is deployed from an image registry…

Ah yeah, our app is deployed straight from GitHub and really wanted to avoid more work here that seems unnecessary in the short to medium term.

I think if that’s the only solution Qovery is willing to accept here, just another line in the “reasons to just contract out a devops engineer ASAP and get off Qovery” line for us haha

It’s your choice of course. But in my experience you can switch from github application to container application in only few hours and for so much less than a devops engineer :stuck_out_tongue_winking_eye: (but maybe your use case is more complicated than mine)

  • Create a registry on aws
  • Use github action to build you container (instead of Qovery)
  • Use Qovery CLI to start deploying your application

Hi there,

trialing qovery here and kinda stuck on the same issue.

Here’s a bit of a context.

We have a service written in rust that exposes two things: a) a grpc server, b) a consumer application

Because building this app takes some time and we want to reduce our github actions run times, we pretty much use a single dockerfile with multi stage builds that runs two different applications in two different stages.

While I’m aware stages probably weren’t built for this use case - would have been nicer if I could just tell qovery to stop building at some stage. (docker does it!)

Docker reference: Stop at a specific build stage

excerpt of a docker file


RUN cargo build --release --bins

FROM gcr.io/distroless/cc-debian12 as redacted_grpc_server
COPY --from=builder /app/redacted/target/release/redacted-grpc-server /app/redacted-grpc-server
WORKDIR /app
CMD ["./redacted-grpc-server"]

FROM gcr.io/distroless/cc-debian12 as redacted_consumer
COPY --from=builder /app/redacted/target/release/redacted-consumer /app/redacted-consumer
WORKDIR /app
CMD ["./redacted-consumer"]

Hi @noots-globally you can build your images on github and deploy your application by using qovery cli

This is an example of my github action file if it can help you

name: Publish Docker image and Deploy with Qovery

on:
  workflow_call:
    inputs:
      xxx
    secrets:
      xxx

jobs:
  deploy_with_qovery:
    name: Push Docker image to ECR and Deploy with Qovery
    runs-on: ubuntu-latest
    environment: ${{ xxx }}
    timeout-minutes: 14
    steps:
      - name: Check out the repo
        uses: actions/checkout@v3

      - name: Log in to Docker Hub
        uses: docker/login-action@v2.1.0
        with:
          registry: <registry_url>
          username: ${{ xxx }}
          password: ${{ xxx }}

      - name: Extract metadata (tags, labels) for Docker web
        id: meta_web
        uses: docker/metadata-action@v4.1.1
        with:
          images: <docker_image_registry_url_for_web>
          tags: |
            type=semver,pattern={{version}}
            type=sha,prefix=${{ xxx }}-,format=long

      - name: Extract metadata (tags, labels) for Docker cli
        id: meta_cli
        uses: docker/metadata-action@v4.1.1
        with:
          images: <docker_image_registry_url_for_cli>
          tags: |
            type=semver,pattern={{version}}
            type=sha,prefix=${{ xxx }}-,format=long

      - name: Build and push Docker image for web
        uses: docker/build-push-action@v4
        with:
          context: .
          target: <your_dockerfile_target>
          push: true
          build-args: |
            xxx
          tags: ${{ steps.meta_web.outputs.tags }}
          labels: ${{ steps.meta_web.outputs.labels }}

      - name: Build and push Docker image for cli
        uses: docker/build-push-action@v4
        with:
          context: .
          target: <your_dockerfile_target>
          push: true
          build-args: |
            xxx
          tags: ${{ steps.meta_cli.outputs.tags }}
          labels: ${{ steps.meta_cli.outputs.labels }}

      - name: Deploy with Qovery
        shell: bash
        env:
          QOVERY_CLI_ACCESS_TOKEN: ${{ xxx }}
        run: |
          # Download and install Qovery CLI
          curl -s https://get.qovery.com | bash

          qovery container deploy \
            --organization "xxx" \
            --project "xxx" \
            --environment ${{ xxx }} \
            --containers "xxx" \
            --tag ${{ steps.meta_web.outputs.version }} \
            --watch

1 Like