From ae74f33a2753de68efb51b8a72d0bbac2204e5c6 Mon Sep 17 00:00:00 2001 From: Daniel Ekman Date: Tue, 28 Jan 2025 12:56:01 +0100 Subject: [PATCH] Add build context to compose (#680) * Add build context to compose Signed-off-by: Daniel Ekman * Update Docker documentation with build instructions Enhance Docker deployment documentation by: - Adding detailed instructions for building Docker images - Providing two methods for image building (Docker Compose and manual) - Clarifying how to use local images with docker-compose.override.yml --------- Signed-off-by: Daniel Ekman Co-authored-by: Julien Nahum --- docker-compose.yml | 9 +++++++++ docs/deployment/docker.mdx | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9e694a9c..6d028617 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,9 @@ services: api: &api image: jhumanj/opnform-api:latest + build: + context: . + dockerfile: docker/Dockerfile.api environment: &api-environment # Add this anchor DB_HOST: db REDIS_HOST: redis @@ -18,6 +21,9 @@ services: api-worker: image: jhumanj/opnform-api:latest + build: + context: . + dockerfile: docker/Dockerfile.api command: php artisan queue:work environment: <<: *api-environment @@ -29,6 +35,9 @@ services: ui: image: jhumanj/opnform-client:latest + build: + context: . + dockerfile: docker/Dockerfile.client env_file: - ./client/.env diff --git a/docs/deployment/docker.mdx b/docs/deployment/docker.mdx index 288afa3f..d90de9cd 100644 --- a/docs/deployment/docker.mdx +++ b/docs/deployment/docker.mdx @@ -67,7 +67,25 @@ We recommend using these official images for your OpnForm deployment. ## Building Your Own Docker Images -If you prefer to build your own Docker images, you can do so using the provided Dockerfiles in the repository: +By default, OpnForm uses pre-built images from Docker Hub. However, if you want to build the images yourself (for development or customization), you have two options: + +### Option 1: Using Docker Compose (Recommended) + +The simplest way to build the images is using Docker Compose: + +```bash +docker compose build +``` + +This will build all the necessary images. You can then start the application as usual: + +```bash +docker compose up -d +``` + +### Option 2: Building Images Manually + +You can also build the images manually using the provided Dockerfiles: 1. Build the API image: ```bash @@ -79,6 +97,8 @@ If you prefer to build your own Docker images, you can do so using the provided docker build -t opnform-ui:local -f docker/Dockerfile.client . ``` +If you build the images manually, make sure to update your docker-compose.override.yml to use these local images (see below). + ### Overriding Docker Compose Configuration You can override the default Docker Compose configuration by creating a `docker-compose.override.yml` file. This allows you to customize various aspects of the deployment without modifying the main `docker-compose.yml` file.