Explorar o código

Arm64 and check Compose v2 support (#177)

add support of arm64 architecture for the following samples: 
* aspnet-mssql
* elasticsearch-logstash-kibana
* nginx-aspnet-mysql
* nginx-flask-mysql
* nginx-golang-mysql
* react-java-mysql
* sparkjava-mysql
* wordpress-mysql
* react-express-mysql
* react-express-mongodb

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
Guillaume Lours %!s(int64=4) %!d(string=hai) anos
pai
achega
4bba832f88

+ 8 - 1
aspnet-mssql/README.md

@@ -20,7 +20,10 @@ services:
     ports:
     ports:
     - 80:80
     - 80:80
   db:
   db:
-    image: microsoft/mssql-server-linux
+    # mssql server image isn't available for arm64 architecture, so we use azure-sql instead
+    image: mcr.microsoft.com/azure-sql-edge:1.0.4
+    # If you really want to use MS SQL Server, uncomment the following line
+    #image: mcr.microsoft.com/mssql/server
     ...
     ...
 ```
 ```
 The compose file defines an application with two services `web` and `db`. The image for the web service is built with the Dockerfile inside the `app` directory (build parameter).
 The compose file defines an application with two services `web` and `db`. The image for the web service is built with the Dockerfile inside the `app` directory (build parameter).
@@ -28,6 +31,10 @@ The compose file defines an application with two services `web` and `db`. The im
 When deploying the application, docker-compose maps the container port 80 to port 80 of the host as specified in the file.
 When deploying the application, docker-compose maps the container port 80 to port 80 of the host as specified in the file.
 Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
 Make sure port 80 on the host is not being used by another container, otherwise the port should be changed.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use Azure SQL Edge as database instead of MS SQL Server.  
+> You still can use the MS SQL Server image by uncommenting the following line in the Compose file   
+> `#image: mcr.microsoft.com/mssql/server`
 
 
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 

+ 4 - 1
aspnet-mssql/docker-compose.yaml

@@ -7,7 +7,10 @@ services:
     environment:
     environment:
       ACCEPT_EULA: "Y"
       ACCEPT_EULA: "Y"
       SA_PASSWORD: example_123
       SA_PASSWORD: example_123
-    image: mcr.microsoft.com/mssql/server
+    # mssql server image isn't available for arm64 architecture, so we use azure-sql instead
+    image: mcr.microsoft.com/azure-sql-edge:1.0.4
+    # If you really want to use MS SQL Server, uncomment the following line
+    #image: mcr.microsoft.com/mssql/server
     restart: always
     restart: always
     healthcheck:
     healthcheck:
         test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P example_123 -Q 'SELECT 1' || exit 1"]
         test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P example_123 -Q 'SELECT 1' || exit 1"]

+ 1 - 1
elasticsearch-logstash-kibana/README.md

@@ -46,7 +46,7 @@ After the application starts, navigate to below links in your web browser:
 
 
 * Elasticsearch: [`http://localhost:9200`](http://localhost:9200)
 * Elasticsearch: [`http://localhost:9200`](http://localhost:9200)
 * Logstash: [`http://localhost:9600`](http://localhost:9600)
 * Logstash: [`http://localhost:9600`](http://localhost:9600)
-* Kibana: [`http://localhost:5601`](http://localhost:5601)
+* Kibana: [`http://localhost:5601/api/status`](http://localhost:5601/api/status)
 
 
 Stop and remove the containers
 Stop and remove the containers
 ```
 ```

+ 3 - 3
elasticsearch-logstash-kibana/docker-compose.yml

@@ -1,6 +1,6 @@
 services:
 services:
   elasticsearch:
   elasticsearch:
-    image: elasticsearch:7.8.0
+    image: elasticsearch:7.14.2
     container_name: es
     container_name: es
     environment:
     environment:
       discovery.type: single-node
       discovery.type: single-node
@@ -16,7 +16,7 @@ services:
     networks:
     networks:
       - elastic
       - elastic
   logstash:
   logstash:
-    image: logstash:7.8.0
+    image: logstash:7.14.2
     container_name: log
     container_name: log
     environment:
     environment:
       discovery.seed_hosts: logstash
       discovery.seed_hosts: logstash
@@ -35,7 +35,7 @@ services:
       - elastic
       - elastic
     command: logstash -f /usr/share/logstash/pipeline/logstash-nginx.config
     command: logstash -f /usr/share/logstash/pipeline/logstash-nginx.config
   kibana:
   kibana:
-    image: kibana:7.8.0
+    image: kibana:7.14.2
     container_name: kib
     container_name: kib
     ports:
     ports:
       - "5601:5601"
       - "5601:5601"

+ 9 - 1
nginx-aspnet-mysql/README.md

@@ -24,7 +24,10 @@ services:
     build: backend
     build: backend
     ...
     ...
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
   proxy:
   proxy:
     build: proxy
     build: proxy
@@ -36,6 +39,11 @@ The compose file defines an application with three services `proxy`, `backend` a
 When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
 When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
 Make sure port 80 on the host is not already being in use.
 Make sure port 80 on the host is not already being in use.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```

+ 1 - 1
nginx-aspnet-mysql/backend/aspnetapp.csproj

@@ -3,6 +3,6 @@
     <TargetFramework>net5.0</TargetFramework>
     <TargetFramework>net5.0</TargetFramework>
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="MySql.Data" Version="8.0.23" />
+    <PackageReference Include="MySqlConnector" Version="0.61.0" />
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 8 - 4
nginx-aspnet-mysql/docker-compose.yaml

@@ -1,17 +1,21 @@
 services:
 services:
   backend:
   backend:
     build: backend
     build: backend
+    restart: always
     secrets:
     secrets:
       - db-password
       - db-password
     depends_on: 
     depends_on: 
       - db
       - db
     environment:
     environment:
       - ASPNETCORE_URLS=http://+:8000
       - ASPNETCORE_URLS=http://+:8000
-    depends_on:
-      db:
-        condition: service_healthy
+#    depends_on:
+#      db:
+#        condition: service_healthy
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     command: '--default-authentication-plugin=mysql_native_password'
     command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     healthcheck:
     healthcheck:

+ 9 - 1
nginx-flask-mysql/README.md

@@ -21,7 +21,10 @@ services:
     build: backend
     build: backend
     ...
     ...
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
   proxy:
   proxy:
     build: proxy
     build: proxy
@@ -31,6 +34,11 @@ The compose file defines an application with three services `proxy`, `backend` a
 When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
 When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
 Make sure port 80 on the host is not already being in use.
 Make sure port 80 on the host is not already being in use.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```

+ 4 - 1
nginx-flask-mysql/docker-compose.yaml

@@ -1,6 +1,9 @@
 services:
 services:
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     command: '--default-authentication-plugin=mysql_native_password'
     command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     healthcheck:
     healthcheck:

+ 9 - 1
nginx-golang-mysql/README.md

@@ -24,7 +24,10 @@ services:
     build: backend
     build: backend
     ...
     ...
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
   proxy:
   proxy:
     build: proxy
     build: proxy
@@ -36,6 +39,11 @@ The compose file defines an application with three services `proxy`, `backend` a
 When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
 When deploying the application, docker-compose maps port 80 of the proxy service container to port 80 of the host as specified in the file.
 Make sure port 80 on the host is not already being in use.
 Make sure port 80 on the host is not already being in use.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```

+ 4 - 1
nginx-golang-mysql/docker-compose.yaml

@@ -7,7 +7,10 @@ services:
       db:
       db:
         condition: service_healthy
         condition: service_healthy
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     command: '--default-authentication-plugin=mysql_native_password'
     command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     healthcheck:
     healthcheck:

+ 2 - 6
react-express-mongodb/backend/db/index.js

@@ -7,11 +7,7 @@ exports.connect = (app) => {
   const options = {
   const options = {
     useNewUrlParser: true,
     useNewUrlParser: true,
     autoIndex: false, // Don't build indexes
     autoIndex: false, // Don't build indexes
-    reconnectTries: 30, // Retry up to 30 times
-    reconnectInterval: 500, // Reconnect every 500ms
-    poolSize: 10, // Maintain up to 10 socket connections
-    // If not connected, return errors immediately rather than waiting for reconnect
-    bufferMaxEntries: 0,
+      maxPoolSize: 10, // Maintain up to 10 socket connections
   };
   };
 
 
   const connectWithRetry = () => {
   const connectWithRetry = () => {
@@ -24,7 +20,7 @@ exports.connect = (app) => {
         app.emit("ready");
         app.emit("ready");
       })
       })
       .catch((err) => {
       .catch((err) => {
-        console.log("MongoDB connection unsuccessful, retry after 2 seconds.");
+        console.log("MongoDB connection unsuccessful, retry after 2 seconds.", err);
         setTimeout(connectWithRetry, 2000);
         setTimeout(connectWithRetry, 2000);
       });
       });
   };
   };

+ 1 - 1
react-express-mongodb/frontend/Dockerfile

@@ -1,5 +1,5 @@
 # Create image based on the official Node image from dockerhub
 # Create image based on the official Node image from dockerhub
-FROM node:lts-buster-slim
+FROM node:lts-buster
 
 
 # Create app directory
 # Create app directory
 WORKDIR /usr/src/app
 WORKDIR /usr/src/app

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 475 - 370
react-express-mongodb/frontend/package-lock.json


+ 1 - 1
react-express-mongodb/frontend/package.json

@@ -8,7 +8,7 @@
     "@testing-library/user-event": "^7.2.1",
     "@testing-library/user-event": "^7.2.1",
     "axios": "^0.21.4",
     "axios": "^0.21.4",
     "bootstrap": "^4.3.1",
     "bootstrap": "^4.3.1",
-    "node-sass": "^6.0.1",
+    "sass": "^1.43.4",
     "react": "^16.13.1",
     "react": "^16.13.1",
     "react-dom": "^16.13.1",
     "react-dom": "^16.13.1",
     "react-scripts": "^4.0.3"
     "react-scripts": "^4.0.3"

+ 9 - 1
react-express-mysql/README.md

@@ -27,7 +27,10 @@ services:
       - 9230:9230
       - 9230:9230
     ...
     ...
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
   frontend:
   frontend:
     build: frontend
     build: frontend
@@ -39,6 +42,11 @@ The compose file defines an application with three services `frontend`, `backend
 When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
 When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
 Make sure port 3000 on the host is not already being in use.
 Make sure port 3000 on the host is not already being in use.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```

+ 4 - 1
react-express-mysql/docker-compose.yaml

@@ -28,7 +28,10 @@ services:
     depends_on:
     depends_on:
       - db
       - db
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     command: '--default-authentication-plugin=mysql_native_password'
     command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     secrets:
     secrets:

+ 9 - 1
react-java-mysql/README.md

@@ -23,7 +23,10 @@ services:
     build: backend
     build: backend
     ...
     ...
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
   frontend:
   frontend:
     build: frontend
     build: frontend
@@ -35,6 +38,11 @@ The compose file defines an application with three services `frontend`, `backend
 When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.  
 When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.  
 Make sure port 3000 on the host is not already being in use.
 Make sure port 3000 on the host is not already being in use.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```

+ 6 - 3
react-java-mysql/docker-compose.yaml

@@ -13,10 +13,13 @@ services:
       db:
       db:
         condition: service_healthy
         condition: service_healthy
   db:
   db:
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.19
     environment:
     environment:
-      MYSQL_DATABASE: example
-      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password
-    image: mysql:8.0.19
+      - MYSQL_DATABASE=example
+      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
     restart: always
     restart: always
     healthcheck:
     healthcheck:
       test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
       test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]

+ 9 - 1
sparkjava-mysql/README.md

@@ -22,13 +22,21 @@ services:
     ports:
     ports:
     - 8080:8080
     - 8080:8080
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
 ```
 ```
 The compose file defines an application with two services `backend` and `db`.
 The compose file defines an application with two services `backend` and `db`.
 When deploying the application, docker-compose maps port 8080 of the backend service container to port 80 of the host as specified in the file.
 When deploying the application, docker-compose maps port 8080 of the backend service container to port 80 of the host as specified in the file.
 Make sure port 8080 on the host is not already being in use.
 Make sure port 8080 on the host is not already being in use.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```

+ 4 - 1
sparkjava-mysql/docker-compose.yaml

@@ -6,7 +6,10 @@ services:
     secrets:
     secrets:
       - db-password
       - db-password
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     restart: always
     restart: always
     secrets:
     secrets:
       - db-password
       - db-password

+ 14 - 6
wordpress-mysql/README.md

@@ -1,5 +1,5 @@
-## Wordpress with MySQL
-This example defines one of the basic setups for Wordpress. More details on how this works can be found on the official [wordpress image page](https://hub.docker.com/_/wordpress).
+## WordPress with MySQL
+This example defines one of the basic setups for WordPress. More details on how this works can be found on the official [WordPress image page](https://hub.docker.com/_/wordpress).
 
 
 
 
 Project structure:
 Project structure:
@@ -13,7 +13,10 @@ Project structure:
 ```
 ```
 services:
 services:
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     ...
     ...
   wordpress:
   wordpress:
     image: wordpress:latest
     image: wordpress:latest
@@ -23,9 +26,14 @@ services:
     ...
     ...
 ```
 ```
 
 
-When deploying this setup, docker-compose maps the wordpress container port 80 to
+When deploying this setup, docker-compose maps the WordPress container port 80 to
 port 80 of the host as specified in the compose file.
 port 80 of the host as specified in the compose file.
 
 
+> ℹ️ **_INFO_**  
+> For compatibility purpose between `AMD64` and `ARM64` architecture, we use a MariaDB as database instead of MySQL.  
+> You still can use the MySQL image by uncommenting the following line in the Compose file   
+> `#image: mysql:8.0.27`
+
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
 ```
 ```
@@ -48,7 +56,7 @@ CONTAINER ID        IMAGE               COMMAND                  CREATED
 e0884a8d444d        mysql:8.0.19        "docker-entrypoint.s…"   35 seconds ago      Up 34 seconds       3306/tcp, 33060/tcp   wordpress-mysql_db_1
 e0884a8d444d        mysql:8.0.19        "docker-entrypoint.s…"   35 seconds ago      Up 34 seconds       3306/tcp, 33060/tcp   wordpress-mysql_db_1
 ```
 ```
 
 
-Navigate to `http://localhost:80` in your web browser to access Wordpress.
+Navigate to `http://localhost:80` in your web browser to access WordPress.
 
 
 ![page](output.jpg)
 ![page](output.jpg)
 
 
@@ -58,7 +66,7 @@ Stop and remove the containers
 $ docker-compose down
 $ docker-compose down
 ```
 ```
 
 
-To remove all Wordpress data, delete the named volumes by passing the `-v` parameter:
+To remove all WordPress data, delete the named volumes by passing the `-v` parameter:
 ```
 ```
 $ docker-compose down -v
 $ docker-compose down -v
 ```
 ```

+ 4 - 1
wordpress-mysql/docker-compose.yaml

@@ -1,6 +1,9 @@
 services:
 services:
   db:
   db:
-    image: mysql:8.0.19
+    # We use a mariadb image which supports both amd64 & arm64 architecture
+    image: mariadb:10.6.4-focal
+    # If you really want to use MySQL, uncomment the following line
+    #image: mysql:8.0.27
     command: '--default-authentication-plugin=mysql_native_password'
     command: '--default-authentication-plugin=mysql_native_password'
     volumes:
     volumes:
       - db_data:/var/lib/mysql
       - db_data:/var/lib/mysql

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio