forked from asecurityteam/sdcli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
105 lines (76 loc) · 3 KB
/
Dockerfile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
FROM golang:1.12.4 AS BASE
ENV APT_MAKE_VERSION=4.1-9.1 \
APT_GCC_VERSION=4:6.3.0-4 \
APT_GIT_VERSION=1:2.11.0-3+deb9u4 \
GOLANGCI_VERSION=v1.16.0 \
LANG=C.UTF-8
#########################################
FROM BASE AS SYSTEM_DEPS
# Install apt dependencies
RUN apt-get update && \
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
make=${APT_MAKE_VERSION} \
gcc=${APT_GCC_VERSION} \
git=${APT_GIT_VERSION} \
bc \
jq && \
apt-get upgrade -y
#########################################
FROM SYSTEM_DEPS AS GO_DEPS
# Install dep
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# Install gocov tools
RUN go get github.com/axw/gocov/... && \
go install github.com/axw/gocov/gocov && \
go get github.com/AlekSi/gocov-xml && \
go install github.com/AlekSi/gocov-xml && \
go get github.com/wadey/gocovmerge && \
go install github.com/wadey/gocovmerge
# Install lint
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin ${GOLANGCI_VERSION}
#########################################
FROM GO_DEPS AS JS_DEPS
# Install NPM
RUN curl -sfL https://deb.nodesource.com/setup_11.x | bash - && \
apt-get install -y nodejs
#########################################
FROM JS_DEPS AS PYTHON_DEPS
RUN apt-get install -y locales
RUN curl https://bootstrap.pypa.io/get-pip.py | python3
RUN pip3 install -U setuptools cookiecutter
RUN sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen
RUN pip3 install -U pylint
RUN pip3 install coverage
RUN pip3 install pytest
RUN pip3 install pytest-cov
RUN pip3 install pipenv
RUN pip3 install oyaml
RUN pip3 install python-slugify
RUN pip3 install --upgrade git+git://github.com/asecurityteam/ccextender
RUN pip3 install yamllint
#########################################
FROM PYTHON_DEPS AS SSH_DEPS
# Install the bitbucket SSH host
RUN mkdir -p /home/sdcli/.ssh
RUN echo 'bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==' >> /home/sdcli/.ssh/known_hosts
#########################################
FROM SSH_DEPS AS USER_DEPS
# Create a non-root user to avoid permissions issues when
# modifying files on the mounted host directories.
RUN groupadd -r sdcli -g 1000 \
&& useradd --no-log-init -r -g sdcli -u 1000 sdcli \
&& chown -R sdcli:sdcli /opt \
&& chown -R sdcli:sdcli /go \
&& chown -R sdcli:sdcli /home/sdcli \
&& chown -R sdcli:sdcli /usr/local
#########################################
FROM USER_DEPS
USER sdcli
RUN mkdir -p /home/sdcli/oss-templates/
COPY ./oss-templates/ /home/sdcli/oss-templates/
COPY ./commands/* /usr/bin/
ENTRYPOINT [ "sdcli" ]