-
Notifications
You must be signed in to change notification settings - Fork 15
/
docker_to_sh.sh
35 lines (24 loc) · 944 Bytes
/
docker_to_sh.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
#!/bin/bash
# This converts a docker file to a shell file
# Almost guaranteed to not work with many Docker files, but hey, it works for us
HOME_DIRECTORY=/home/dev
CONVERT_HOME_DIRECTORY=1
INPUT=Dockerfile
OUTPUT=Dockerfile.sh
cp -f $INPUT $OUTPUT
# Convert FROM, MAINTAINER, VOLUME to comments
sed -i "s/^FROM\s/# FROM /g" $OUTPUT
sed -i "s/^MAINTAINER\s/# MAINTAINER /g" $OUTPUT
sed -i "s/^VOLUME\s/# VOLUME /g" $OUTPUT
# Get rid of RUNs
sed -i "s/^RUN\s//g" $OUTPUT
# Convert home directory into squiggles (tildes)
sed -i "s/$HOME_DIRECTORY/~/g" $OUTPUT
# Convert ENVs into EXPORTs
sed -r 's/^ENV\s([A-Z]*)\s*([a-z]*)/export \1=\2/g' -i $OUTPUT
# Get rid of EXPOSE todo: open up ports based on these?
sed -i "s/^EXPOSE\s/# EXPOSE /g" $OUTPUT
# Convert ADDs into cp
sed -i "s/^ADD\s/cp /g" $OUTPUT
# Timestamp
sed -i '1s/^/# Generated by docker_to_sh, for all your shoddy bash script from Dockerfile generation needs. \n/' $OUTPUT