From 741370fdbcdc730211b14b1359e82026f0c2c00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 12 Jul 2022 18:56:13 +0200 Subject: [PATCH 1/5] Remove 'image' entries in 'docker-compose.override.yml' and 'docker-compose.yml' files --- docker-compose.override.yml | 8 ++++---- docker-compose.yml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 3d63da9e3..2583ea77c 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -5,7 +5,7 @@ services: # FRONTEND ############################################# ######################################################## frontend: - image: gradido/frontend:development + # image: gradido/frontend:development build: target: development environment: @@ -22,7 +22,7 @@ services: # ADMIN INTERFACE ###################################### ######################################################## admin: - image: gradido/admin:development + # image: gradido/admin:development build: target: development environment: @@ -39,7 +39,7 @@ services: # BACKEND ############################################## ######################################################## backend: - image: gradido/backend:development + # image: gradido/backend:development build: target: development networks: @@ -65,7 +65,7 @@ services: # feel free to change this behaviour if it seems useful # Due to problems with the volume caching the built files # we changed this to test build. This keeps the service running. - image: gradido/database:test_up + # image: gradido/database:test_up build: target: test_up environment: diff --git a/docker-compose.yml b/docker-compose.yml index 213b200cd..26a1ecbe2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: # FRONTEND ############################################# ######################################################## frontend: - image: gradido/frontend:latest + # image: gradido/frontend:latest build: context: ./frontend target: production @@ -35,7 +35,7 @@ services: # ADMIN INTERFACE ###################################### ######################################################## admin: - image: gradido/admin:latest + # image: gradido/admin:latest build: context: ./admin target: production @@ -77,7 +77,7 @@ services: # BACKEND ############################################## ######################################################## backend: - image: gradido/backend:latest + # image: gradido/backend:latest build: # since we have to include the entities from ./database we cannot define the context as ./backend # this might blow build image size to the moon ?! From 597394b0b3cae2a8066298b43a0eb0c8d2c6385f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 12 Jul 2022 18:56:38 +0200 Subject: [PATCH 2/5] Add 'docker-compose.apple-m1.override.yml' --- docker-compose.apple-m1.override.yml | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docker-compose.apple-m1.override.yml diff --git a/docker-compose.apple-m1.override.yml b/docker-compose.apple-m1.override.yml new file mode 100644 index 000000000..7cf3efd3e --- /dev/null +++ b/docker-compose.apple-m1.override.yml @@ -0,0 +1,52 @@ +# This file defines the Apple M1 chip settings. It overrides docker-compose.override.yml, +# which defines the development settings. +# To use it it is required to explicitly define if you want to build with it: +# > docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.apple-m1.override.yml up + +version: "3.4" + +services: + ######################################################## + # FRONTEND ############################################# + ######################################################## + frontend: + platform: linux/amd64 + + ######################################################## + # ADMIN INTERFACE ###################################### + ######################################################## + admin: + platform: linux/amd64 + + ######################################################### + ## MARIADB ############################################## + ######################################################### + mariadb: + platform: linux/amd64 + + ######################################################## + # BACKEND ############################################## + ######################################################## + backend: + platform: linux/amd64 + + ######################################################## + # DATABASE ############################################# + ######################################################## + database: + platform: linux/amd64 + + ######################################################### + ## NGINX ################################################ + ######################################################### + nginx: + platform: linux/amd64 + +networks: + external-net: + internal-net: + internal: true + +volumes: + db_vol: + From 45013efd8da7fb5c366ddb1592650a3e897f624b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 18 Jul 2022 12:02:56 +0200 Subject: [PATCH 3/5] Remove forgotten to delete lines in Docker Compose Apple M1 override --- docker-compose.apple-m1.override.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docker-compose.apple-m1.override.yml b/docker-compose.apple-m1.override.yml index 7cf3efd3e..72152f9ae 100644 --- a/docker-compose.apple-m1.override.yml +++ b/docker-compose.apple-m1.override.yml @@ -41,12 +41,3 @@ services: ######################################################### nginx: platform: linux/amd64 - -networks: - external-net: - internal-net: - internal: true - -volumes: - db_vol: - From b7c49b2410ce18c7fdf6eca4ab0fd94553717445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 18 Jul 2022 12:24:29 +0200 Subject: [PATCH 4/5] Change Docker Compose image names and add comments wy --- docker-compose.override.yml | 19 ++++++++++++------- docker-compose.test.yml | 1 + docker-compose.yml | 13 +++++++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 2583ea77c..9d3e0b8d4 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,11 +1,13 @@ version: "3.4" services: + ######################################################## # FRONTEND ############################################# ######################################################## frontend: - # image: gradido/frontend:development + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/frontend:local-development build: target: development environment: @@ -22,7 +24,8 @@ services: # ADMIN INTERFACE ###################################### ######################################################## admin: - # image: gradido/admin:development + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/admin:local-development build: target: development environment: @@ -39,7 +42,8 @@ services: # BACKEND ############################################## ######################################################## backend: - # image: gradido/backend:development + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/backend:local-development build: target: development networks: @@ -62,10 +66,11 @@ services: ######################################################## database: # we always run on production here since else the service lingers - # feel free to change this behaviour if it seems useful - # Due to problems with the volume caching the built files - # we changed this to test build. This keeps the service running. - # image: gradido/database:test_up + # feel free to change this behaviour if it seems useful + # Due to problems with the volume caching the built files + # we changed this to test build. This keeps the service running. + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/database:local-test_up build: target: test_up environment: diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 221ecba20..7db318176 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -6,6 +6,7 @@ services: # BACKEND ############################################## ######################################################## backend: + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there image: gradido/backend:test build: target: test diff --git a/docker-compose.yml b/docker-compose.yml index 26a1ecbe2..6c0dffe15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,11 +6,13 @@ version: "3.4" services: + ######################################################## # FRONTEND ############################################# ######################################################## frontend: - # image: gradido/frontend:latest + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/frontend:local-production build: context: ./frontend target: production @@ -35,7 +37,8 @@ services: # ADMIN INTERFACE ###################################### ######################################################## admin: - # image: gradido/admin:latest + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/admin:local-production build: context: ./admin target: production @@ -77,7 +80,8 @@ services: # BACKEND ############################################## ######################################################## backend: - # image: gradido/backend:latest + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/backend:local-production build: # since we have to include the entities from ./database we cannot define the context as ./backend # this might blow build image size to the moon ?! @@ -108,7 +112,8 @@ services: # DATABASE ############################################# ######################################################## database: - #image: gradido/database:production_up + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/database:local-production_up build: context: ./database target: production_up From 4338328690bedc4087f058bc953ad8fd9ee2ba54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 18 Jul 2022 12:40:13 +0200 Subject: [PATCH 5/5] Add Docker documentation in DOCKER_MORE_CLOSELY.md --- DOCKER_MORE_CLOSELY.md | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 DOCKER_MORE_CLOSELY.md diff --git a/DOCKER_MORE_CLOSELY.md b/DOCKER_MORE_CLOSELY.md new file mode 100644 index 000000000..f2aae81c7 --- /dev/null +++ b/DOCKER_MORE_CLOSELY.md @@ -0,0 +1,44 @@ +# Docker More Closely + +## Apple M1 Platform + +***Attention:** For using Docker commands in Apple M1 environments!* + +### Enviroment Variable For Apple M1 Platform + +To set the Docker platform environment variable in your terminal tab, run: + +```bash +# set env variable for your shell +$ export DOCKER_DEFAULT_PLATFORM=linux/amd64 +``` + +### Docker Compose Override File For Apple M1 Platform + +For Docker compose `up` or `build` commands, you can use our Apple M1 override file that specifies the M1 platform: + +```bash +# in main folder + +# for development +$ docker compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.apple-m1.override.yml up + +# for production +$ docker compose -f docker-compose.yml -f docker-compose.apple-m1.override.yml up +``` + +## Analysing Docker Builds + +To analyze a Docker build, there is a wonderful tool called [dive](https://github.com/wagoodman/dive). Please sponsor if you're using it! + +The `dive build` command is exactly the right one to fulfill what we are looking for. +We can use it just like the `docker build` command and get an analysis afterwards. + +So, in our main folder, we use it in the following way: + +```bash +# in main folder +$ dive build --target -t "gradido/:local-" / +``` + +For the specific applications, see our [publish.yml](.github/workflows/publish.yml).