-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-setup.sh
41 lines (32 loc) · 1.27 KB
/
docker-setup.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
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
cd $HOME
# install java
sudo apt install -y default-jre
# clone repo & build executable jar
git clone https://github.com/mbruzina/sample-rest-api.git && \
cd sample-rest-api/ && \
./gradlew bootJar && \
./gradlew downloadNewrelic && \
./gradlew unzipNewrelic
# install docker dependencies and keys
sudo apt-get update && \
sudo apt-get install -y ca-certificates curl gnupg && \
sudo install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# repo setup
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# install docker and friends
sudo apt-get update && \
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# validate installation
sudo docker run hello-world
# build our sample-rest-api image
sudo docker build -t derp/sample-rest-api .
# run it
sudo docker run -p 8080:8080 derp/sample-rest-api
# generate traffic by curling api/hello
# curl http://localhost:8080/api/hello