-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.forWebservice
156 lines (117 loc) · 4.86 KB
/
Dockerfile.forWebservice
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Docker container to run SVSHI, the Secured and Verified Smart Home Infrastructure
# COMMANDS:
# BUILD:
## docker build -t svshi:ubuntu22.04 .
# START AND RUN (execute from `svshi` folder):
## 'docker run --rm -v $PWD:/pwd -d --name svshi -i svshi:ubuntu22.04 && docker exec -it svshi /bin/bash'
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND noninteractive
# Install npm
RUN apt-get update --fix-missing
RUN apt-get update --fix-missing
# Installing basic packages
RUN apt-get update --fix-missing
RUN apt-get install -y apt-utils
RUN apt-get install -y software-properties-common
RUN add-apt-repository universe
RUN apt-get install -y zip
RUN apt-get install -y unzip
RUN apt-get install -y build-essential
RUN apt-get install -y jq
RUN apt-get install -y curl
RUN apt-get install -y wget
RUN apt-get install -y rubygems
RUN apt-get install -y gcc
RUN apt-get install -y gdb
RUN apt-get install -y python3.9
RUN apt-get install -y wget
RUN apt-get install -y git
RUN apt-get install -y nano
RUN apt-get install -y openjdk-11-jdk scala
RUN apt-get install -y sudo
RUN apt-get install -y net-tools
RUN apt-get install apt-transport-https curl gnupg -yqq
RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list
RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list
RUN curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
RUN chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
RUN apt-get update --fix-missing
RUN apt-get install sbt
# To solve issues when running on non-Unix system
RUN apt-get install -y dos2unix
# Install pip3
RUN apt-get install -y python3-distutils
RUN apt-get install -y python3-pip
# Change root's password
RUN echo 'root:nigiri' | chpasswd
# Add non-root user
RUN useradd -rm -d /home/maki -s /bin/bash -g root -G sudo -u 1001 maki
RUN echo 'maki:maki' | chpasswd
USER maki
WORKDIR /home/maki
# Install pip3 as maki
RUN pip3 install -U pip
# Update env variables
ENV PATH="/home/maki/.local/lib/python3.9/site-packages:${PATH}"
ENV PATH="/home/maki/.local/bin:${PATH}"
ENV PATH="/home/maki/local/bin:${PATH}"
ENV SVSHI_HOME="/home/maki/svshi"
RUN rm -rf ${SVSHI_HOME}
RUN mkdir ${SVSHI_HOME}
# Copy the files
COPY . ${SVSHI_HOME}/
USER root
# Remove used folders
RUN rm -rf ${SVSHI_HOME}/__pycache__
RUN rm -rf ${SVSHI_HOME}/.github
RUN rm -rf ${SVSHI_HOME}/.metal
RUN rm -rf ${SVSHI_HOME}/assignments
RUN rm -rf ${SVSHI_HOME}/deletedApps
RUN rm -rf ${SVSHI_HOME}/generated
RUN rm -rf ${SVSHI_HOME}/installedApps
RUN rm -rf ${SVSHI_HOME}/logs
RUN rm -rf ${SVSHI_HOME}/prototypes
RUN rm -rf ${SVSHI_HOME}/target
RUN rm -rf ${SVSHI_HOME}/temp
RUN rm -rf ${SVSHI_HOME}/src/__pycache__
RUN rm -rf ${SVSHI_HOME}/src/.bsp
RUN rm -rf ${SVSHI_HOME}/src/.pytest_cache
RUN rm -rf ${SVSHI_HOME}/src/.vscode
RUN rm -rf ${SVSHI_HOME}/src/app_library
RUN rm -rf ${SVSHI_HOME}/src/temp_ets_parser
RUN rm -rf ${SVSHI_HOME}/src/svshi_private_server_logs
RUN rm -rf ${SVSHI_HOME}/src/target
RUN rm -rf ${SVSHI_HOME}/src/temp
RUN rm -rf ${SVSHI_HOME}/src/build_release.sh
RUN rm -rf ${SVSHI_HOME}/src/get_python_coverage.sh
RUN rm -rf ${SVSHI_HOME}/src/get-pip.py
RUN rm -rf ${SVSHI_HOME}/src/run_tests.bat
RUN rm -rf ${SVSHI_HOME}/src/run_tests.sh
RUN rm -rf ${SVSHI_HOME}/src/get-pip.py
RUN rm -rf ${SVSHI_HOME}/src/core/.bsp
RUN rm -rf ${SVSHI_HOME}/src/core/.metals
RUN rm -rf ${SVSHI_HOME}/src/core/.idea
RUN rm -rf ${SVSHI_HOME}/src/core/target
RUN rm -rf ${SVSHI_HOME}/src/svshi_gui/
RUN rm -rf ${SVSHI_HOME}/src/web_service
# Files back to UNIX when building from Windows:
RUN find ${SVSHI_HOME}/ -type f -exec dos2unix {} \;
## UNCOMMENT IF YOU WANT TO INSTALL CROSSHAIR FROM SOURCE and change the pip3 install below (e.g. if you forked the repo) -----------------------
# # Install crosshair from main branch of the repo FROM SOURCE
# RUN cd /home/maki/ && mkdir crosshair_local
# RUN cd /home/maki/crosshair_local && git clone https://github.com/pschanely/CrossHair.git
# ENV VIRTUAL_ENV=/home/maki/sushi_python_env
# RUN python3 -m venv $VIRTUAL_ENV
# ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# RUN cd /home/maki/crosshair_local/CrossHair && pip3 install --editable .
## UNCOMMENT IF YOU WANT TO INSTALL CROSSHAIR FROM SOURCE and change the pip3 install below (e.g. if you forked the repo) -----------------------
# Install SVSHI
RUN cd ${SVSHI_HOME}/src/core && sbt "pack; packInstall"
RUN cd ${SVSHI_HOME}/src/ && python3 -m pip install -r requirements.txt
RUN cp -r /root/local/ /home/maki
RUN chown -R maki ${SVSHI_HOME}/
USER maki
EXPOSE 4242
ENTRYPOINT svshi gui -a $(hostname -i):4242
# COMMAND TO RUN CONTAINER:
# docker run --rm -d -p 4242:4242 -v svshiForWebserviceVolume:/home/maki/ --name svshi_for_webservice -i svshi_for_webservice:ubuntu22.04