DEV Community

Ayrton
Ayrton

Posted on

5 2

Best Makefile for Docker project (M1 Compatible)

Hi !

Here is the best Makefile ever,

It's now easy to use Registry Gitlab to push your docker images and use repo name as image name.

REGISTRY_ID=$(shell grep gitlab.com .git/config|sed 's/url = https:\/\//registry./g'|sed -e "s/\.git$$//g"|xargs)
TAG=$(shell git symbolic-ref --short -q HEAD|sed -e 's/master$$/latest/g'|sed 's/\([a-zA-Z]*\)\//\1-/g')

build:
    docker build -t $(REGISTRY_ID):$(TAG) .

run: build
    docker run --rm $(REGISTRY_ID):$(TAG) 

dev:
    docker run --rm $(REGISTRY_ID):$(TAG) 

push:
    docker push $(REGISTRY_ID):$(TAG)

pushm1:
    docker buildx build --platform linux/amd64 --push -t $(REGISTRY_ID):$(TAG) .

buildm1:
    docker buildx build --platform linux/amd64 -t $(REGISTRY_ID):$(TAG) .
Enter fullscreen mode Exit fullscreen mode

Realy easy to use:

Build images
make build

Push images
make push

Run images
make run

Test images
make dev`

For Mac M1 Chip, to use for build AMD64 images

Build for amd64 when your use macbook m1
make buildm1

Push for amd64
make pushm1

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post