Skip to content

Commit df7793a

Browse files
Updated Powershell version of the lifecycle scripts to inline the setup.sh scripts in the same way as the bash lifecycle scripts do.
1 parent 8966e4f commit df7793a

24 files changed

+103
-87
lines changed

_template/build.ps1

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Containerized Dev Tools
2+
# Copyright © 2018, Matheson Ventures Pte Ltd
3+
#
4+
# This is free software: you can redistribute it and/or modify it under the
5+
# terms of the GNU General Public License v2 as published by the Free Software
6+
# Foundation.
7+
#
8+
# This software is distributed in the hope that it will be useful, but WITHOUT
9+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11+
# details.
12+
#
13+
# You should have received a copy of the GNU General Public License along with
14+
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
15+
16+
#
17+
# Get and filter setup.sh
18+
#
19+
20+
$lineFilter = $("\#.*", "^\s*$")
21+
$lines = (Get-Content ".\setup.sh" | Select-String -Pattern $lineFilter -NotMatch)
22+
$setup = $lines -Join "`r`n"
23+
$setup = $setup -replace "\\`r`n", " "
24+
$lines = $setup -split "`r`n"
25+
$lines = $lines -replace "^", "RUN "
26+
$setup = $lines -Join "`r`n"
27+
28+
#
29+
# Generate Dockerfile
30+
#
31+
32+
$dockerfile = (Get-Content ".\Dockerfile.template") -Join "`r`n"
33+
$dockerfile = $dockerfile.Replace("SETUP", $setup)
34+
35+
Set-Content -Path ".\Dockerfile" $dockerfile
36+
37+
#
38+
# Build Docker Image
39+
#
40+
41+
$prefix = Get-Content container_prefix
42+
$name = Get-Content container_name
43+
$containerName = "$prefix/$name"
44+
45+
docker build -t $containerName .
46+
47+
#
48+
# Clean Up
49+
#
50+
51+
Remove-Item -Path Dockerfile

awscli/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

awscli/run.ps1

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

2121
docker run -it --rm `
2222
--name $instanceName `
23-
--mount source=wrk,target=/dat/wrk `
24-
--mount source=awscli,target=/root/.aws `
25-
-v /var/run/docker.sock:/var/run/docker.sock `
2623
$containerName
27-

awscli/setup.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1717

1818
# Pre-requisites
19-
apt-get update; apt-get install -y \
19+
apt-get update -y; apt-get upgrade -y;
20+
21+
apt-get install -y \
2022
wget
2123

2224
wget https://bootstrap.pypa.io/get-pip.py
2325
python get-pip.py
2426

2527
pip install awscli --upgrade --user
26-

basedeb/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

basedeb/run.ps1

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

2121
docker run -it --rm `
2222
--name $instanceName `
2323
$containerName
24-

basedeb/setup.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
# You should have received a copy of the GNU General Public License along with
1616
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1717

18-
apt-get update; apt-get upgrade; apt-get install -y \
18+
# Pre-requisites
19+
echo 'Acquire::http { Proxy "http://192.168.2.5:3142"; }' >> /etc/apt/apt.conf.d/proxy; \
20+
apt-get update -y; \
21+
apt-get upgrade -y;
22+
23+
apt-get install -y \
1924
curl \
2025
dnsutils \
2126
git \
@@ -24,4 +29,3 @@ apt-get update; apt-get upgrade; apt-get install -y \
2429
tmux \
2530
vim \
2631
wget
27-

dockerdeb/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

dockerdeb/run.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

2121
docker run -it --rm `
2222
--name $instanceName `
23-
--mount source=wrk,target=/dat/wrk `
24-
-v /var/run/docker.sock:/var/run/docker.sock `
2523
$containerName
26-

dockerdeb/setup.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# You should have received a copy of the GNU General Public License along with
1616
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1717

18+
# Pre-requisites
19+
apt-get update -y; apt-get upgrade -y;
20+
1821
apt-get install -y \
1922
apt-transport-https \
2023
ca-certificates \
@@ -30,4 +33,3 @@ add-apt-repository \
3033
stable"
3134

3235
apt-get update -y; apt-get install -y docker-ce;
33-

jdk8/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

jdk8/run.ps1

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

21-
docker run -it `
21+
docker run -it --rm `
2222
--name $instanceName `
23-
--mount source=wrk,target=/dat/wrk `
2423
$containerName
25-

jdk8/setup.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
# You should have received a copy of the GNU General Public License along with
1616
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1717

18-
apt-get update; apt-get install -y software-properties-common
18+
# Pre-requisites
19+
apt-get update -y; apt-get upgrade -y;
20+
21+
apt-get install -y software-properties-common
1922

2023
add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
2124

@@ -28,4 +31,3 @@ echo debconf shared/accepted-oracle-license-v1-1 seen true | \
2831
debconf-set-selections
2932

3033
apt-get install -y --allow-unauthenticated oracle-java8-installer
31-

kops/Dockerfile.template

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
FROM mv/devtools/awscli:latest
1717

18-
COPY setup.sh /tmp
19-
RUN /tmp/setup.sh
20-
RUN rm /tmp/setup.sh
18+
SETUP
2119

2220
ENV PATH="${PATH}:/root/.local/bin"
23-

kops/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

kops/run.ps1

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

2121
docker run -it --rm `
2222
--name $instanceName `
23-
--mount source=wrk,target=/dat/wrk `
24-
--mount source=awscli,target=/root/.aws `
25-
-v /var/run/docker.sock:/var/run/docker.sock `
2623
$containerName
27-

kops/setup.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1717

1818
# Pre-requisites
19-
apt-get update; apt-get install -y \
19+
apt-get update -y; apt-get upgrade -y;
20+
21+
apt-get install -y \
2022
wget
2123

2224
# kubectl
@@ -28,4 +30,3 @@ mv ./kubectl /root/.local/bin/
2830
wget -O kops https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
2931
chmod +x ./kops
3032
mv ./kops /root/.local/bin/
31-

nodejs10/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

nodejs10/run.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

2121
docker run -it --rm `
2222
--name $instanceName `
23-
--mount source=wrk,target=/dat/wrk `
24-
-v /var/run/docker.sock:/var/run/docker.sock `
2523
$containerName
26-

nodejs10/setup.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
# https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
2020

2121
# Pre-requisites
22-
apt-get update; apt-get install -y \
22+
apt-get update -y; apt-get upgrade -y;
23+
24+
apt-get install -y \
2325
curl
2426

2527
curl -sL https://deb.nodesource.com/setup_10.x | bash -
2628

2729
apt-get install -y nodejs
28-

nodejs8/build.ps1

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html
1515

16-
$prefix = Get-Content container_prefix
17-
$name = Get-Content container_name
18-
$containerName = "$prefix/$name"
19-
20-
docker build -t $containerName .
21-
16+
& ..\_template\build.ps1

nodejs8/run.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
$prefix = Get-Content container_prefix
1717
$name = Get-Content container_name
1818
$containerName = "$prefix/$name"
19-
$instanceName = "$($name)-prod"
19+
$instanceName = "$($name -replace '/', '_')-prod"
2020

2121
docker run -it --rm `
2222
--name $instanceName `
23-
--mount source=wrk,target=/dat/wrk `
24-
-v /var/run/docker.sock:/var/run/docker.sock `
2523
$containerName
26-

nodejs8/setup.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
# https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
2020

2121
# Pre-requisites
22-
apt-get update; apt-get install -y \
22+
apt-get update -y; apt-get upgrade -y;
23+
24+
apt-get install -y \
2325
curl
2426

2527
curl -sL https://deb.nodesource.com/setup_8.x | bash -
2628

2729
apt-get install -y nodejs
28-

readme.md

+11
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ Note that the build script will generate the Dockerfile from Dockerfile.template
6363

6464
## Running Dev Tools via Docker
6565

66+
### Image Dependency Overview
67+
68+
The images defined in this project have dependencies that you need to follow when building up the images from scratch. Read this table from left to right to follow the dependencies:
69+
70+
| L1 | L2 | L3 | L4 |
71+
| ------- | --------- | ------ | ---- |
72+
| basedeb | jdk8 | | |
73+
| | nodejs8 | | |
74+
| | nodejs10 | | |
75+
| | dockerdeb | awscli | kops |
76+
6677
### basedeb
6778

6879
The `basedeb` tool is just the library/debian image from Docker Hub with a number of commonly required dev tools installed - specifically:

0 commit comments

Comments
 (0)