File tree Expand file tree Collapse file tree 7 files changed +136
-29
lines changed Expand file tree Collapse file tree 7 files changed +136
-29
lines changed Original file line number Diff line number Diff line change 1
1
language : bash
2
2
services : docker
3
3
4
+ env :
5
+ - VARIANT=debian
6
+ - VARIANT=alpine
7
+
4
8
install :
5
9
- git clone https://github.com/docker-library/official-images.git ~/official-images
6
10
7
11
before_script :
8
12
- env | sort
9
- - image=' ghost'
13
+ - image=" ghost:$VARIANT"
10
14
11
15
script :
12
- - travis_retry docker build -t "$image" .
16
+ - travis_retry docker build -t "$image" "$VARIANT"
13
17
- ~/official-images/test/run.sh "$image"
14
18
15
19
after_script :
Original file line number Diff line number Diff line change
1
+ # http://support.ghost.org/supported-node-versions/
2
+ # https://github.com/nodejs/LTS
3
+ FROM node:4-alpine
4
+
5
+ # grab su-exec for easy step-down from root
6
+ RUN apk add --no-cache 'su-exec>=0.2'
7
+
8
+ RUN apk add --no-cache \
9
+ # add "bash" for "[["
10
+ bash \
11
+ # add "tar" for "--one-file-system"
12
+ tar
13
+
14
+ ENV GHOST_SOURCE /usr/src/ghost
15
+ WORKDIR $GHOST_SOURCE
16
+
17
+ ENV GHOST_VERSION 0.11.7
18
+
19
+ RUN set -ex; \
20
+ \
21
+ apk add --no-cache --virtual .build-deps \
22
+ ca-certificates \
23
+ gcc \
24
+ make \
25
+ openssl \
26
+ python \
27
+ unzip \
28
+ ; \
29
+ \
30
+ wget -O ghost.zip "https://github.com/TryGhost/Ghost/releases/download/${GHOST_VERSION}/Ghost-${GHOST_VERSION}.zip" ; \
31
+ unzip ghost.zip; \
32
+ \
33
+ npm install --production; \
34
+ \
35
+ apk del .build-deps; \
36
+ \
37
+ rm ghost.zip; \
38
+ npm cache clean; \
39
+ rm -rf /tmp/npm*
40
+
41
+ ENV GHOST_CONTENT /var/lib/ghost
42
+ RUN mkdir -p "$GHOST_CONTENT" \
43
+ && chown -R node:node "$GHOST_CONTENT" \
44
+ # Ghost expects "config.js" to be in $GHOST_SOURCE, but it's more useful for
45
+ # image users to manage that as part of their $GHOST_CONTENT volume, so we
46
+ # symlink.
47
+ && ln -s "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
48
+ VOLUME $GHOST_CONTENT
49
+
50
+ COPY docker-entrypoint.sh /usr/local/bin/
51
+ ENTRYPOINT ["docker-entrypoint.sh" ]
52
+
53
+ EXPOSE 2368
54
+ CMD ["npm" , "start" ]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ # allow the container to be started with `--user`
5
+ if [[ " $* " == npm* start* ]] && [ " $( id -u) " = ' 0' ]; then
6
+ chown -R node " $GHOST_CONTENT "
7
+ exec su-exec node " $BASH_SOURCE " " $@ "
8
+ fi
9
+
10
+ if [[ " $* " == npm* start* ]]; then
11
+ baseDir=" $GHOST_SOURCE /content"
12
+ for dir in " $baseDir " /* / " $baseDir " /themes/* /; do
13
+ targetDir=" $GHOST_CONTENT /${dir# $baseDir / } "
14
+ mkdir -p " $targetDir "
15
+ if [ -z " $( ls -A " $targetDir " ) " ]; then
16
+ tar -c --one-file-system -C " $dir " . | tar xC " $targetDir "
17
+ fi
18
+ done
19
+
20
+ if [ ! -e " $GHOST_CONTENT /config.js" ]; then
21
+ sed -r '
22
+ s/127\.0\.0\.1/0.0.0.0/g;
23
+ s!path.join\(__dirname, (.)/content!path.join(process.env.GHOST_CONTENT, \1!g;
24
+ ' " $GHOST_SOURCE /config.example.js" > " $GHOST_CONTENT /config.js"
25
+ fi
26
+ fi
27
+
28
+ exec " $@ "
Original file line number Diff line number Diff line change @@ -21,21 +21,28 @@ WORKDIR $GHOST_SOURCE
21
21
22
22
ENV GHOST_VERSION 0.11.7
23
23
24
- RUN buildDeps=' \
24
+ RUN set -ex; \
25
+ \
26
+ buildDeps=' \
25
27
gcc \
26
28
make \
27
29
python \
28
30
unzip \
29
- ' \
30
- && set -x \
31
- && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
32
- && wget -O ghost.zip "https://github.com/TryGhost/Ghost/releases/download/${GHOST_VERSION}/Ghost-${GHOST_VERSION}.zip" \
33
- && unzip ghost.zip \
34
- && npm install --production \
35
- && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
36
- && rm ghost.zip \
37
- && npm cache clean \
38
- && rm -rf /tmp/npm*
31
+ ' ; \
32
+ apt-get update; \
33
+ apt-get install -y $buildDeps --no-install-recommends; \
34
+ rm -rf /var/lib/apt/lists/*; \
35
+ \
36
+ wget -O ghost.zip "https://github.com/TryGhost/Ghost/releases/download/${GHOST_VERSION}/Ghost-${GHOST_VERSION}.zip" ; \
37
+ unzip ghost.zip; \
38
+ \
39
+ npm install --production; \
40
+ \
41
+ apt-get purge -y --auto-remove $buildDeps; \
42
+ \
43
+ rm ghost.zip; \
44
+ npm cache clean; \
45
+ rm -rf /tmp/npm*
39
46
40
47
ENV GHOST_CONTENT /var/lib/ghost
41
48
RUN mkdir -p "$GHOST_CONTENT" \
@@ -46,8 +53,9 @@ RUN mkdir -p "$GHOST_CONTENT" \
46
53
&& ln -s "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
47
54
VOLUME $GHOST_CONTENT
48
55
49
- COPY docker-entrypoint.sh /entrypoint.sh
50
- ENTRYPOINT ["/entrypoint.sh" ]
56
+ COPY docker-entrypoint.sh /usr/local/bin/
57
+ RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
58
+ ENTRYPOINT ["docker-entrypoint.sh" ]
51
59
52
60
EXPOSE 2368
53
61
CMD ["npm" , "start" ]
File renamed without changes.
Original file line number Diff line number Diff line change @@ -41,19 +41,32 @@ join() {
41
41
echo " ${out# $sep } "
42
42
}
43
43
44
- commit=" $( dirCommit .) "
44
+ for variant in debian alpine; do
45
+ commit=" $( dirCommit " $variant " ) "
45
46
46
- fullVersion=" $( git show " $commit " :Dockerfile | awk ' $1 == "ENV" && $2 == "GHOST_VERSION" { print $3; exit }' ) "
47
+ fullVersion=" $( git show " $commit " :" $variant / Dockerfile" | awk ' $1 == "ENV" && $2 == "GHOST_VERSION" { print $3; exit }' ) "
47
48
48
- versionAliases=()
49
- while [ " ${fullVersion% .* } " != " $fullVersion " ]; do
50
- versionAliases+=( $fullVersion )
51
- fullVersion=" ${fullVersion% .* } "
52
- done
53
- versionAliases+=( $fullVersion latest )
49
+ versionAliases=()
50
+ while [ " ${fullVersion% .* } " != " $fullVersion " ]; do
51
+ versionAliases+=( $fullVersion )
52
+ fullVersion=" ${fullVersion% .* } "
53
+ done
54
+ versionAliases+=(
55
+ $fullVersion
56
+ latest
57
+ )
58
+
59
+ variantAliases=( " ${versionAliases[@]/%/ -$variant } " )
60
+ variantAliases=( " ${variantAliases[@]// latest-/ } " )
54
61
55
- echo
56
- cat << -EOE
57
- Tags: $( join ' , ' " ${versionAliases[@]} " )
58
- GitCommit: $commit
59
- EOE
62
+ if [ " $variant " = ' debian' ]; then
63
+ variantAliases=( " ${versionAliases[@]} " )
64
+ fi
65
+
66
+ echo
67
+ cat << -EOE
68
+ Tags: $( join ' , ' " ${variantAliases[@]} " )
69
+ GitCommit: $commit
70
+ Directory: $variant
71
+ EOE
72
+ done
Original file line number Diff line number Diff line change @@ -12,4 +12,4 @@ current="$(
12
12
) "
13
13
14
14
set -x
15
- sed -ri ' s/^(ENV GHOST_VERSION) .*/\1 ' " $current " ' /' Dockerfile
15
+ sed -ri ' s/^(ENV GHOST_VERSION) .*/\1 ' " $current " ' /' * / Dockerfile
You can’t perform that action at this time.
0 commit comments