mjuvilla commited on
Commit
a6fff02
·
1 Parent(s): ea23e3c

modified dockerfile and added script to setup environment, library building and asset downloading so when can run this script not only on docker

Browse files
Dockerfile CHANGED
@@ -1,8 +1,4 @@
1
  FROM python:3.12-slim
2
-
3
- RUN apt-get update && \
4
- apt-get install -y libgomp1 openjdk-21-jre-headless wget unzip libgoogle-perftools-dev libsparsehash-dev git cmake build-essential
5
-
6
  # Set up a new user named "user" with user ID 1000
7
  RUN useradd -m -u 1000 user
8
 
@@ -18,32 +14,11 @@ WORKDIR $HOME/app
18
 
19
  COPY --chown=user fast_align_config ./fast_align_config
20
  COPY --chown=user src ./src
 
21
  COPY --chown=user gradio_app.py .
22
  COPY --chown=user requirements.txt .
23
 
24
- # download and compile fast align
25
- RUN git clone https://github.com/clab/fast_align.git fast_align_src && \
26
- cd fast_align_src && \
27
- mkdir build && \
28
- cd build && \
29
- cmake .. && \
30
- make
31
-
32
- # download fastalign config files
33
- RUN pip install gdown
34
- RUN gdown https://drive.google.com/uc\?id\=1OS-qbYLAgLJ2n4cpk9usNdTcNARjNaSr -O fast_align_config.zip
35
- RUN unzip -u fast_align_config.zip
36
-
37
- # build fastalign
38
- RUN cp fast_align_src/build/fast_align .
39
- RUN cp fast_align_src/build/atools .
40
- RUN rm -rf fast_align_src
41
-
42
- # download okapi tikal
43
- RUN wget https://okapiframework.org/binaries/main/1.47.0/okapi-apps_gtk2-linux-x86_64_1.47.0.zip
44
- RUN unzip okapi-apps_gtk2-linux-x86_64_1.47.0.zip -d okapi-apps_gtk2-linux-x86_64_1.47.0
45
-
46
- RUN pip install -r requirements.txt
47
- RUN python -m spacy download xx_ent_wiki_sm
48
 
49
  CMD ["python", "gradio_app.py"]
 
1
  FROM python:3.12-slim
 
 
 
 
2
  # Set up a new user named "user" with user ID 1000
3
  RUN useradd -m -u 1000 user
4
 
 
14
 
15
  COPY --chown=user fast_align_config ./fast_align_config
16
  COPY --chown=user src ./src
17
+ COPY --chown=user scripts ./scripts
18
  COPY --chown=user gradio_app.py .
19
  COPY --chown=user requirements.txt .
20
 
21
+ ENV DOCKER_ENV=1
22
+ RUN bash scripts/setup_env.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  CMD ["python", "gradio_app.py"]
fast_align_config/ca-en.err DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8e71c52a2613da65481b6aaaaee5c662f974e58c58cbbaff545d88d1a9db19ac
3
- size 112471
 
 
 
 
fast_align_config/ca-en.params DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ba38de4abff7295e380538828a0aa79ce2b958926654712b3cb88f5e0b57b6dc
3
- size 161586440
 
 
 
 
fast_align_config/en-ca.err DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:58a11d7e116b14919e4d1661f22d3384fec6213525dfbedfafc5e07d2aaf9a10
3
- size 112474
 
 
 
 
fast_align_config/en-ca.params DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c31fda85b2ce44a1b2c6a1d8a618bf5fc9714b9d4122bbb0119e261dc1ad57f8
3
- size 230876059
 
 
 
 
scripts/setup_env.sh ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ # create and activate venv if not already in Docker
4
+ if [ -z "$DOCKER_ENV" ]; then
5
+ if [ ! -d ".venv" ]; then
6
+ echo "Creating virtual environment..."
7
+ python3.12 -m venv .venv
8
+ fi
9
+ source .venv/bin/activate
10
+
11
+ echo "Please make sure you have the following packages installed:"
12
+ echo "sudo apt-get install libgomp1 openjdk-21-jre-headless wget unzip \\"
13
+ echo "libgoogle-perftools-dev libsparsehash-dev git cmake build-essential"
14
+ else
15
+ apt-get update && \
16
+ apt-get install -y --no-install-recommends \
17
+ libgomp1 \
18
+ openjdk-21-jre-headless \
19
+ wget \
20
+ unzip \
21
+ libgoogle-perftools-dev \
22
+ libsparsehash-dev \
23
+ git \
24
+ cmake \
25
+ build-essential
26
+ fi
27
+
28
+ # download and compile fast align
29
+ git clone https://github.com/clab/fast_align.git fast_align_src
30
+ cd fast_align_src
31
+ mkdir build && cd build
32
+ cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
33
+ make
34
+ cd ../..
35
+
36
+ cp fast_align_src/build/fast_align .
37
+ cp fast_align_src/build/atools .
38
+ rm -rf fast_align_src
39
+
40
+ # download fastalign config files
41
+ pip install gdown
42
+ gdown https://drive.google.com/uc\?id\=1OS-qbYLAgLJ2n4cpk9usNdTcNARjNaSr -O fast_align_config.zip
43
+ unzip -o fast_align_config.zip
44
+ rm -rf fast_align_config.zip
45
+
46
+ # download okapi tikal
47
+ wget https://okapiframework.org/binaries/main/1.47.0/okapi-apps_gtk2-linux-x86_64_1.47.0.zip
48
+ unzip -o okapi-apps_gtk2-linux-x86_64_1.47.0.zip -d okapi-apps_gtk2-linux-x86_64_1.47.0
49
+
50
+ pip install -r requirements.txt
51
+ python -m spacy download xx_ent_wiki_sm