Skip to content

Commit 2353cf8

Browse files
committed
Refactor Dockerfile into a single file with targets to better support arm64
1 parent 2e3332f commit 2353cf8

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

Dockerfile

+43-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,45 @@ ARG TARGET=server
22
ARG GOPROXY
33

44
##### Temporal builder #####
5-
FROM temporalio/base-builder:1.2.0 AS temporal-builder
5+
FROM golang:1.16-alpine AS base-builder
6+
7+
RUN apk add --update --no-cache \
8+
make \
9+
git \
10+
protobuf \
11+
build-base
12+
13+
14+
##### dockerize builder: built from source to support arm & x86 #####
15+
FROM base-builder AS dockerize-builder
16+
RUN mkdir -p /xsrc && \
17+
git clone https://github.com/jwilder/dockerize.git && \
18+
cd dockerize && \
19+
go mod init github.com/jwilder/dockerize && \
20+
go mod tidy && \
21+
go build -o /usr/local/bin/dockerize .
22+
23+
##### base server image #####
24+
FROM alpine:3.12 AS base-server
25+
26+
RUN apk add --update --no-cache \
27+
ca-certificates \
28+
openssl \
29+
bash \
30+
curl \
31+
vim
32+
33+
# set up nsswitch.conf for Go's "netgo" implementation
34+
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-424546457
35+
RUN test ! -e /etc/nsswitch.conf && echo 'hosts: files dns' > /etc/nsswitch.conf
36+
COPY --from=dockerize-builder /usr/local/bin/dockerize /usr/local/bin/dockerize
37+
SHELL ["/bin/bash", "-c"]
38+
39+
##### temporal-base-server target #####
40+
FROM base-server AS temporal-base-server
41+
42+
##### temporal-builder target #####
43+
FROM base-builder AS temporal-builder
644

745
WORKDIR /temporal
846

@@ -12,8 +50,8 @@ RUN go mod download
1250
COPY . .
1351
RUN make bins
1452

15-
##### Temporal server #####
16-
FROM temporalio/base-server:1.0.0 AS temporal-server
53+
##### temporal-server target #####
54+
FROM temporal-base-server AS temporal-server
1755
WORKDIR /etc/temporal
1856
ENV TEMPORAL_HOME /etc/temporal
1957
ENV SERVICES "history:matching:frontend:worker"
@@ -48,13 +86,13 @@ CMD ["autosetup", "develop"]
4886
COPY docker/setup-develop.sh /etc/temporal/setup-develop.sh
4987

5088
##### Temporal CLI (tctl) #####
51-
FROM temporalio/base-server:1.0.0 AS temporal-tctl
89+
FROM temporal-base-server AS temporal-tctl
5290
WORKDIR /etc/temporal
5391
ENTRYPOINT ["tctl"]
5492
COPY --from=temporal-builder /temporal/tctl /usr/local/bin
5593

5694
##### Temporal admin tools #####
57-
FROM temporalio/base-admin-tools:1.0.0 as temporal-admin-tools
95+
FROM temporal-base-server as temporal-admin-tools
5896
WORKDIR /etc/temporal
5997
# Keep the container running.
6098
ENTRYPOINT ["tail", "-f", "/dev/null"]

0 commit comments

Comments
 (0)