88 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| # php-fpm
 | |
| 
 | |
| - These containes are meant to be used as base images for app container with custom nginx container that expects volume from fpm container.
 | |
| 
 | |
| ## Multi-arch support
 | |
| - Install emualtor:
 | |
| ```bash
 | |
| docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-* #Uninstall existing
 | |
| docker run --privileged --rm tonistiigi/binfmt --install all
 | |
| ```
 | |
| - You may need to set these variable before running build if you have pre Docker v23
 | |
| ```bash
 | |
| export COMPOSE_DOCKER_CLI_BUILD=1
 | |
| export DOCKER_BUILDKIT=1
 | |
| ```
 | |
| Enable (1) or disable (0) BuildKit builds
 | |
| 
 | |
| #### Adding new version
 | |
| - copy one of the folders in this repo with new version number and edit Docker file in the new folder as needed.
 | |
| 
 | |
| #### Building new container
 | |
| - `cd` into a folder and run `docker buildx bake --load`
 | |
| 
 | |
| #### Pushing built container to registry
 | |
| - `cd` into a folder and run `docker buildx bake --push`
 | |
| 
 | |
| ###
 | |
| - Avoid adding app specifc depdencies to base images.
 | |
| 
 | |
| ### Custom building
 | |
| - go to app repo and create a .build dir and create `docker-compose.yml` with the following content:
 | |
| ```yaml
 | |
| version: '3.5'
 | |
| services:
 | |
| #########################
 | |
|   fpm:
 | |
|     build:
 | |
|       context: ../
 | |
|       dockerfile: .build/fpm.Dockerfile
 | |
|       x-bake:
 | |
|         pull: true
 | |
|         platforms:
 | |
|           - linux/amd64/v1
 | |
|           - linux/amd64/v2
 | |
|           - linux/amd64/v3
 | |
|           - linux/arm/v7
 | |
|           - linux/arm64
 | |
|       hostname: fpm
 | |
|       image: git.shihaam.dev/dockerfiles/<app>/fpm
 | |
| #########################
 | |
|   nginx:
 | |
|     build:
 | |
|       context: .
 | |
|       dockerfile: nginx.Dockerfile
 | |
|       x-bake:
 | |
|         pull: true
 | |
|         platforms:
 | |
|           - linux/amd64/v1
 | |
|           - linux/amd64/v2
 | |
|           - linux/amd64/v3
 | |
|           - linux/arm/v7
 | |
|           - linux/arm64
 | |
|      hostname: nginx
 | |
|      image: git.shihaam.dev/dockerfiles/<app>/nginx
 | |
| ```
 | |
| ## running the app
 | |
| - Save the following in project dir as `docker-compose.yml`  and run `docker compose up`
 | |
| ```yaml
 | |
| version: '3.5'
 | |
| services:
 | |
| #########################
 | |
|    fpm:
 | |
|       hostname: fpm
 | |
|       image: git.shihaam.dev/dockerfiles/<app>/fpm
 | |
|       env_file:
 | |
|          - env
 | |
|       volumes:
 | |
|          - ./public:/var/www/html/storage/app/public
 | |
| #########################
 | |
|    nginx:
 | |
|       hostname: nginx
 | |
|       image: git.shihaam.dev/dockerfiles/<>/nginx
 | |
|       ports:
 | |
|          - 8000:80
 | |
|       volumes_from:
 | |
|          - fpm
 | |
| ```
 |