-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathDockerfile-VM
67 lines (50 loc) · 1.76 KB
/
Dockerfile-VM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# This image contains Fake Service Consul and Envoy, it can be used to simulate a Virtual Machine containing the Consul Agent
# and Envoy running as Daemon processes.
FROM nicholasjackson/consul-envoy:v1.12.2-v1.21.2 as base
# Setup bash and supervisord etc
RUN apt-get update && \
apt-get install -y supervisor dnsmasq && \
rm -rf /var/lib/apt/lists/*
RUN sed -i 's/\/bin\/ash/\/bin\/bash/g' /etc/passwd
COPY entrypoint.sh /entrypoint.sh
COPY prestart.sh /prestart.sh
RUN chmod +x /entrypoint.sh
RUN chmod +x /prestart.sh
# Setup the supervisor d file
COPY fake-service.conf /etc/supervisor/conf.d/fake-service.conf
# Configure Dnsmasq to use Consul DN
RUN echo "server=/consul/127.0.0.1#8600" > /etc/dnsmasq.d/10-consul
RUN echo "server=127.0.0.11" >> /etc/dnsmasq.d/10-consul
COPY startdnsmasq.sh /startdnsmasq.sh
RUN chmod +x /startdnsmasq.sh
# Copy AMD binaries
FROM base AS image-amd64
COPY bin/linux/amd64/fake-service /app/fake-service
RUN chmod +x /app/fake-service
# Copy Arm 8 binaries
FROM base AS image-arm64
COPY bin/linux/arm64/fake-service /app/fake-service
RUN chmod +x /app/fake-service
FROM image-${TARGETARCH}
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG BUILDPLATFORM
ARG BUILDARCH
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM $TARGETARCH $TARGETVARIANT"
# set default env vars so supervisor
# does not crash on start
ENV CONSUL_HTTP_ADDR=localhost:8500
ENV CONSUL_SERVER=localhost
ENV CONSUL_DATACENTER=dc1
ENV SERVICE_ID=null
ENV CONSUL_RETRY_INTERVAL=5s
ENV PRESTART_FILE=/prestart.sh
# add default config folder
RUN mkdir /config
# data directory for Consul
RUN mkdir -p /etc/consul
# Run supervisord in blocking mode
ENTRYPOINT ["/usr/bin/supervisord"]
CMD ["-c", "/etc/supervisor/supervisord.conf", "-n"]