Skip to content

Commit c551bf4

Browse files
chore: add docker build arguments to Dockerfile.dev (#5017)
1 parent 83d865f commit c551bf4

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Dockerfile.dev

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
FROM golang:1.23 AS build
2+
3+
ARG REACHABILITY_OVERRIDE_PUBLIC=false
4+
ARG BATCHFACTOR_OVERRIDE_PUBLIC=5
5+
6+
WORKDIR /src
7+
# enable modules caching in separate layer
8+
COPY go.mod go.sum ./
9+
RUN go mod download
10+
COPY . ./
11+
12+
RUN make binary \
13+
REACHABILITY_OVERRIDE_PUBLIC=${REACHABILITY_OVERRIDE_PUBLIC} \
14+
BATCHFACTOR_OVERRIDE_PUBLIC=${BATCHFACTOR_OVERRIDE_PUBLIC}
15+
116
FROM debian:12.7-slim
217

318
ENV DEBIAN_FRONTEND=noninteractive
419

520
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
ca-certificates; \
21+
ca-certificates; \
722
apt-get clean; \
823
rm -rf /var/lib/apt/lists/*; \
924
groupadd -r bee --gid 999; \
@@ -12,7 +27,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1227
# make sure mounted volumes have correct permissions
1328
RUN mkdir -p /home/bee/.bee && chown 999:999 /home/bee/.bee
1429

15-
COPY ./tmp/bee /usr/local/bin/bee
30+
COPY --from=build /src/dist/bee /usr/local/bin/bee
1631

1732
EXPOSE 1633 1634
1833
USER bee

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ BEEKEEPER_BRANCH ?= master
1212
REACHABILITY_OVERRIDE_PUBLIC ?= false
1313
BATCHFACTOR_OVERRIDE_PUBLIC ?= 5
1414
BEE_IMAGE ?= ethersphere/bee:latest
15+
PLATFORM ?= linux/amd64
1516

1617
BEE_API_VERSION ?= "$(shell grep '^ version:' openapi/Swarm.yaml | awk '{print $$2}')"
1718

@@ -142,13 +143,14 @@ build: export CGO_ENABLED=0
142143
build:
143144
$(GO) build -trimpath -ldflags "$(LDFLAGS)" ./...
144145

146+
# example: make docker-build PLATFORM=linux/amd64 BEE_IMAGE=ethersphere/bee:latest REACHABILITY_OVERRIDE_PUBLIC=false BATCHFACTOR_OVERRIDE_PUBLIC=5
145147
.PHONY: docker-build
146-
docker-build: binary
147-
@echo "Build flags: $(LDFLAGS)"
148-
mkdir -p ./tmp
149-
cp ./dist/bee ./tmp/bee
150-
docker build -f Dockerfile.dev -t $(BEE_IMAGE) . --no-cache
151-
rm -rf ./tmp
148+
docker-build:
149+
docker build -f Dockerfile.dev \
150+
--platform $(PLATFORM) \
151+
-t $(BEE_IMAGE) . \
152+
--build-arg REACHABILITY_OVERRIDE_PUBLIC=$(REACHABILITY_OVERRIDE_PUBLIC) \
153+
--build-arg BATCHFACTOR_OVERRIDE_PUBLIC=$(BATCHFACTOR_OVERRIDE_PUBLIC)
152154
@echo "Docker image: $(BEE_IMAGE)"
153155

154156
.PHONY: githooks

0 commit comments

Comments
 (0)