moreover commited on
Commit
c94360a
·
1 Parent(s): 5c2f6f1

first commit

Browse files
.ipynb_checkpoints/Dockerfile-checkpoint CHANGED
@@ -111,6 +111,7 @@ RUN useradd -m -u 1000 user
111
  RUN mkdir -p /home/user/execution_engine
112
  COPY --chown=user ./execution_engine /home/user/execution_engine
113
  COPY --chown=user $WORKER_CFG_DB /home/user
 
114
  ENV WORKER_CFG_DB /home/user/worker_cfg_db.csv
115
 
116
  USER user
 
111
  RUN mkdir -p /home/user/execution_engine
112
  COPY --chown=user ./execution_engine /home/user/execution_engine
113
  COPY --chown=user $WORKER_CFG_DB /home/user
114
+ RUN chmod -R 777 /home/user/execution_engine
115
  ENV WORKER_CFG_DB /home/user/worker_cfg_db.csv
116
 
117
  USER user
Dockerfile CHANGED
@@ -111,6 +111,7 @@ RUN useradd -m -u 1000 user
111
  RUN mkdir -p /home/user/execution_engine
112
  COPY --chown=user ./execution_engine /home/user/execution_engine
113
  COPY --chown=user $WORKER_CFG_DB /home/user
 
114
  ENV WORKER_CFG_DB /home/user/worker_cfg_db.csv
115
 
116
  USER user
 
111
  RUN mkdir -p /home/user/execution_engine
112
  COPY --chown=user ./execution_engine /home/user/execution_engine
113
  COPY --chown=user $WORKER_CFG_DB /home/user
114
+ RUN chmod -R 777 /home/user/execution_engine
115
  ENV WORKER_CFG_DB /home/user/worker_cfg_db.csv
116
 
117
  USER user
Dockerfile.bak DELETED
@@ -1,119 +0,0 @@
1
- FROM ubuntu:jammy
2
- WORKDIR /root
3
-
4
- ENV DEBIAN_FRONTEND noninteractive
5
- ENV TZ Etc/UTC
6
-
7
- RUN apt-get update && \
8
- apt-get install -y \
9
- gnupg ca-certificates apt-utils \
10
- build-essential curl unzip && \
11
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
12
- RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list
13
- RUN apt-get update && \
14
- apt-get install -y tzdata
15
-
16
- RUN apt-get install -y mono-devel \
17
- gcc-12 g++-12
18
-
19
- RUN apt-get update && \
20
- apt-get install -y software-properties-common python3.11-dev
21
-
22
- RUN apt-get update && \
23
- apt-get install -y -f libasound2 libc6-i386 libc6-x32 libxi6 libxtst6
24
-
25
- ENV JAVA_PKG=https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz \
26
- JAVA_HOME=/usr/java/jdk-21
27
-
28
- RUN set -eux; \
29
- JAVA_SHA256=$(curl "$JAVA_PKG".sha256) ; \
30
- curl --output /tmp/jdk.tgz "$JAVA_PKG" && \
31
- echo "$JAVA_SHA256 */tmp/jdk.tgz" | sha256sum -c; \
32
- mkdir -p "$JAVA_HOME"; \
33
- tar --extract --file /tmp/jdk.tgz --directory "$JAVA_HOME" --strip-components 1
34
-
35
- RUN curl -OL https://github.com/JetBrains/kotlin/releases/download/v1.7.20/kotlin-compiler-1.7.20.zip
36
- RUN unzip kotlin-compiler-1.7.20.zip -d /usr/local && \
37
- rm kotlin-compiler-1.7.20.zip
38
-
39
- RUN apt-get install -y python2
40
-
41
- RUN curl -OL https://go.dev/dl/go1.19.2.linux-amd64.tar.gz
42
- RUN tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz && \
43
- rm go1.19.2.linux-amd64.tar.gz
44
-
45
- RUN curl -OL https://downloads.python.org/pypy/pypy3.9-v7.3.9-linux64.tar.bz2
46
- RUN tar -C /usr/local -xf pypy3.9-v7.3.9-linux64.tar.bz2 && \
47
- rm pypy3.9-v7.3.9-linux64.tar.bz2
48
-
49
- RUN curl -OL https://downloads.python.org/pypy/pypy2.7-v7.3.9-linux64.tar.bz2
50
- RUN tar -C /usr/local -xf pypy2.7-v7.3.9-linux64.tar.bz2 && \
51
- rm pypy2.7-v7.3.9-linux64.tar.bz2
52
-
53
- RUN apt-get install -y clang-14
54
-
55
- ARG NODE_VERSION=v16.17.1
56
- ARG NODE_DISTRO=linux-x64
57
- ARG NODE_ZIP=node-$NODE_VERSION-$NODE_DISTRO.tar.xz
58
- RUN curl -OL https://nodejs.org/dist/$NODE_VERSION/$NODE_ZIP
59
- RUN tar -C /usr/local -xJvf $NODE_ZIP && \
60
- rm $NODE_ZIP
61
-
62
- ENV RUSTUP_HOME /opt/rust
63
- ENV CARGO_HOME /opt/rust
64
- RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path
65
- RUN apt-get install -y ruby-full
66
-
67
- RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing php8.1
68
- RUN apt-get install -y libgmp-dev libmpfr-dev
69
-
70
- ENV PATH $PATH:/usr/local/go/bin:/usr/local/kotlinc/bin:/usr/local/node-v16.17.1-linux-x64/bin:/opt/rust/bin
71
-
72
- WORKDIR /root
73
-
74
-
75
- RUN update-alternatives --install /usr/bin/java java "$JAVA_HOME"/bin/java 100 && \
76
- update-alternatives --install /usr/bin/javac javac "$JAVA_HOME"/bin/javac 100 && \
77
- update-alternatives --install /usr/bin/jar jar "$JAVA_HOME"/bin/jar 100 && \
78
- update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 && \
79
- update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 && \
80
- update-alternatives --install /usr/bin/python python /usr/bin/python3.11 100 && \
81
- update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 && \
82
- update-alternatives --install /usr/bin/pypy2 pypy2 /usr/local/pypy2.7-v7.3.9-linux64/bin/pypy2 100 && \
83
- update-alternatives --install /usr/bin/pypy3 pypy3 /usr/local/pypy3.9-v7.3.9-linux64/bin/pypy3 100
84
-
85
- RUN apt-get install -y python3-pip gperf
86
- RUN pip install flask gunicorn flask-cors gmpy2 Cython jsonlines fire
87
-
88
- RUN curl -o libseccomp.tar.gz -L https://github.com/seccomp/libseccomp/releases/download/v2.5.4/libseccomp-2.5.4.tar.gz
89
- RUN tar -xzvf libseccomp.tar.gz && cd libseccomp-2.5.4 && chmod +x configure
90
- WORKDIR /root/libseccomp-2.5.4
91
- RUN ./configure --prefix=/usr --enable-python && make
92
- RUN make install
93
- WORKDIR /root/
94
- RUN rm -rf libseccomp*
95
-
96
-
97
- ENV RUN_UID 1586
98
- ENV RUN_GID 1586
99
- ENV NUM_WORKERS 2
100
- ENV GUNICORN_PORT 7860
101
- ENV LOG_LEVEL info
102
-
103
- # RUN groupadd -g ${RUN_GID} runner${RUN_GID} && useradd -M runner${RUN_UID} -g ${RUN_GID} -u ${RUN_UID}
104
-
105
- EXPOSE ${GUNICORN_PORT}
106
- RUN useradd -m -u 1000 user
107
-
108
- RUN mkdir /home/user/execution_engine
109
- COPY --chown=user ./execution_engine /home/user/execution_engine
110
- COPY --chown=user $WORKER_CFG_DB /home/user
111
- ENV WORKER_CFG_DB /home/user/worker_cfg_db.csv
112
- RUN mkdir -p /home/user/code_store
113
- RUN chown -R user:user /code_store
114
-
115
- USER user
116
- ENV PATH="/home/user/.local/bin:$PATH"
117
- WORKDIR /home/user/execution_engine
118
-
119
- CMD ["bash", "start_engine.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
execution_engine/.ipynb_checkpoints/code_store-checkpoint.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import uuid
4
+ from pathlib import Path
5
+
6
+ from config import CodeStoreConfig
7
+
8
+
9
+ class CodeStore:
10
+ _source_dir: Path
11
+
12
+ def __init__(self, cfg: CodeStoreConfig, run_ids: tuple[int, int]) -> None:
13
+ self._source_dir = cfg.source_code_dir / uuid.uuid4().hex
14
+ self.uid = run_ids[1]
15
+ self.gid = run_ids[0]
16
+
17
+ def create(self):
18
+ # os.makedirs(self._source_dir, exist_ok=True)
19
+ # os.chown(self._source_dir, self.uid, self.gid)
20
+ # os.chmod(self._source_dir, 0o775)
21
+ return None
22
+
23
+ def destroy(self) -> None:
24
+ shutil.rmtree(self._source_dir, ignore_errors=True)
25
+
26
+ def write_source_code(self, source_code: str, filename: Path) -> Path:
27
+ filepath = self._source_dir / filename
28
+
29
+ with filepath.open("w") as fp:
30
+ fp.write(source_code)
31
+
32
+ filepath = filepath.resolve()
33
+
34
+ os.chown(filepath, self.uid, self.gid)
35
+ os.chmod(filepath, 0o775)
36
+ return filepath
37
+
38
+ def read_source_code(self, filepath: Path) -> str:
39
+ with filepath.open() as f:
40
+ s = f.read()
41
+
42
+ return s
43
+
44
+
45
+ if __name__ == "__main__":
46
+ from config import load_config
47
+
48
+ cfg = load_config(Path("execution_engine/config.yaml"))
49
+ code_store = CodeStore(cfg.code_store)
50
+ print(
51
+ code_store.read_source_code(
52
+ code_store.write_source_code("""print("Hello")""", Path("main.py"))
53
+ )
54
+ )
execution_engine/code_store.py CHANGED
@@ -15,9 +15,10 @@ class CodeStore:
15
  self.gid = run_ids[0]
16
 
17
  def create(self):
18
- os.makedirs(self._source_dir, exist_ok=True)
19
- os.chown(self._source_dir, self.uid, self.gid)
20
- os.chmod(self._source_dir, 0o775)
 
21
 
22
  def destroy(self) -> None:
23
  shutil.rmtree(self._source_dir, ignore_errors=True)
 
15
  self.gid = run_ids[0]
16
 
17
  def create(self):
18
+ # os.makedirs(self._source_dir, exist_ok=True)
19
+ # os.chown(self._source_dir, self.uid, self.gid)
20
+ # os.chmod(self._source_dir, 0o775)
21
+ return None
22
 
23
  def destroy(self) -> None:
24
  shutil.rmtree(self._source_dir, ignore_errors=True)