-
Notifications
You must be signed in to change notification settings - Fork 2
/
RunInDocker.sh
executable file
·31 lines (26 loc) · 1.07 KB
/
RunInDocker.sh
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
#!/usr/bin/env bash
echo "Only run this script in the root of your code base."
echo "Create Dockerfile using apt.txt"
# Specify which docker to use.
content="FROM ubuntu:jammy\nRUN apt-get update\n"
# Read packages to install.
pkgs='RUN ["apt-get", "install", "--yes", "--no-install-recommends"'
while read -r line;
do
pkgs="${pkgs},\"$line\"" ;
done < apt.txt
pkgs="${pkgs}]\n"
content="${content}${pkgs}"
# Copy codes to target dir and set codes dir to be the working directory.
# Then run compile.sh to compile codes.
content="${content}COPY ./. /MAPF/codes/ \n"
content="${content}WORKDIR /MAPF/codes/ \n"
content="${content}RUN rm -rdf /MAPF/codes/build \n"
content="${content}RUN chmod u+x compile.sh \n"
content="${content}RUN ./compile.sh \n"
echo -e $content > Dockerfile
echo "Remove container and images if exist... ..."
out=$(docker container stop mapf_test 2>&1 ; docker container rm mapf_test 2>&1 ; docker rmi mapf_image 2>&1)
echo "Build image and run the container... ..."
docker build --no-cache -t mapf_image ./
docker container run -it --name mapf_test mapf_image