-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·62 lines (48 loc) · 1.43 KB
/
Dockerfile
File metadata and controls
executable file
·62 lines (48 loc) · 1.43 KB
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
## build stage
FROM golang:1.13.5-alpine3.10 as build-env
# repo
RUN cp /etc/apk/repositories /etc/apk/repositories.bak
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main/" > /etc/apk/repositories
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/community/" >> /etc/apk/repositories
# git
RUN apk update
RUN apk add --no-cache git
# move to GOPATH
RUN mkdir -p /app
WORKDIR /app
# go mod
ENV GOPROXY=https://goproxy.cn
COPY go.mod .
COPY go.sum .
RUN go mod download
# build
COPY . .
COPY etc /app/
RUN go build -o /app/ansible-ext cmd/main.go
## docker image stage
FROM alpine:3.10
# repo
RUN cp /etc/apk/repositories /etc/apk/repositories.bak
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main/" > /etc/apk/repositories
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/community/" >> /etc/apk/repositories
# timezone
RUN apk update
RUN apk add --no-cache py-pip ansible openssh && pip install paramiko
RUN apk add --no-cache tzdata \
&& echo "Asia/Shanghai" > /etc/timezone \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# Add Tini
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
COPY --from=build-env /app /app
# copy config
COPY proto/ansible.swagger.json /app/
COPY etc/init.d/* /etc/init.d/
COPY etc/playbook/* /app/playbook/
RUN mkdir -p /app/playbook/playbook.d
COPY etc/sysconfig/* /etc/sysconfig/
COPY etc/systemd/* /etc/systemd/system/
ENV PORT=50051
EXPOSE 50051
WORKDIR /app
CMD ["/app/ansible-ext"]