-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (39 loc) · 1.14 KB
/
Dockerfile
File metadata and controls
49 lines (39 loc) · 1.14 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
FROM golang:alpine as builder
# Update and grab build packages
RUN apk update && \
apk add --no-cache openssh-client git alpine-sdk libgit2-dev
# Build the tool
RUN mkdir -p /app /go
WORKDIR /app
COPY git-subdir-filter.go .
RUN GOPATH=/go go get -d -v ./...
RUN GOPATH=/go go build -o git-subdir-filter .
FROM alpine:3.8
# Update and get runtime packages
RUN apk update && \
apk add --no-cache openssh-client libgit2>=0.27
RUN mkdir /root/.ssh/
COPY id_rsa.pub /root/.ssh/
COPY id_rsa /root/.ssh/
RUN chmod 400 /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa.pub
RUN eval $(ssh-agent -s)
# XXX Accept the github and gitlab domains
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
RUN ssh-keyscan gitlab.com >> /root/.ssh/known_hosts
# copy binary
RUN mkdir /app
COPY --from=builder /app/git-subdir-filter /app
ARG SOURCE_BRANCH
ARG SOURCE_REPO
ARG TARGET_REPO
ARG FILTER_DIR
ARG WORKDIR
WORKDIR /git
# run in shell form for variable substitution
ENTRYPOINT /app/git-subdir-filter \
-source-repo=$SOURCE_REPO \
-source-branch=$SOURCE_BRANCH \
-target-repo=$TARGET_REPO \
-filter-dir=$FILTER_DIR