doctorray117 / minecraft-ondemand

Templates to deploy a serverless Minecraft Server on demand in AWS
Apache License 2.0
1.68k stars 115 forks source link

Task failed to start when deploying on Arm64 machine (M1 Mac) #43

Open hojongs opened 2 years ago

hojongs commented 2 years ago

Description

I've tried to deploy it on the M1 Mac. When I deployed it without customization code, I've got tasks failed to start issue on AWS ECS. The reason was the failure of the watchdog container. The error message was just exit code 1 on the container in the failed task.

How to fix

https://github.com/doctorray117/minecraft-ondemand/blob/main/cdk/lib/minecraft-stack.ts#L226-L232

-        image: isDockerInstalled()
-          ? ecs.ContainerImage.fromAsset(
-              path.resolve(__dirname, '../../minecraft-ecsfargate-watchdog/')
-            )
-          : ecs.ContainerImage.fromRegistry(
-              'doctorray/minecraft-ecsfargate-watchdog'
-            ),
+        image: ecs.ContainerImage.fromRegistry(
+              'doctorray/minecraft-ecsfargate-watchdog'
+            ),

If the script builds a watchdog image from the asset, you get an arm64 build image. The image doesn't work because the current ECS Task definition use x86 CPU architecture. Otherwise need to config: AWS ECS Doc: Specifying the ARM architecture in your task definition So, I changed the code to get the image from the registry always.

Related issue: #27

Just share my solution to resolve the same issue of others and to improve the code to support arm64 machine efficiently.