シンプルにDockerfile作りたいなと思って実装しました

リポジトリはこちら

https://github.com/hiyashikyuri/go_m1_docker

# Dockerfile
FROM golang:1.16

COPY . /app
WORKDIR /app

RUN go get -u github.com/cosmtrek/air
RUN go mod download

# docker-compose.yml
version: "3"
services:
  app:
    container_name: app
    volumes:
      - ./:/app
    tty: true
    command: "air -c .air.toml"
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 8080:8080

参考記事

【Go 言語】 Docker 上 で Gin を動かすまで