Skip to content

Commit 7251ebf

Browse files
committed
Add initial alpine variant
1 parent f57b040 commit 7251ebf

File tree

7 files changed

+136
-29
lines changed

7 files changed

+136
-29
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
language: bash
22
services: docker
33

4+
env:
5+
- VARIANT=debian
6+
- VARIANT=alpine
7+
48
install:
59
- git clone https://github.com/docker-library/official-images.git ~/official-images
610

711
before_script:
812
- env | sort
9-
- image='ghost'
13+
- image="ghost:$VARIANT"
1014

1115
script:
12-
- travis_retry docker build -t "$image" .
16+
- travis_retry docker build -t "$image" "$VARIANT"
1317
- ~/official-images/test/run.sh "$image"
1418

1519
after_script:

alpine/Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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"]

alpine/docker-entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 "$@"

Dockerfile renamed to debian/Dockerfile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,28 @@ WORKDIR $GHOST_SOURCE
2121

2222
ENV GHOST_VERSION 0.11.7
2323

24-
RUN buildDeps=' \
24+
RUN set -ex; \
25+
\
26+
buildDeps=' \
2527
gcc \
2628
make \
2729
python \
2830
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*
3946

4047
ENV GHOST_CONTENT /var/lib/ghost
4148
RUN mkdir -p "$GHOST_CONTENT" \
@@ -46,8 +53,9 @@ RUN mkdir -p "$GHOST_CONTENT" \
4653
&& ln -s "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
4754
VOLUME $GHOST_CONTENT
4855

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"]
5159

5260
EXPOSE 2368
5361
CMD ["npm", "start"]
File renamed without changes.

generate-stackbrew-library.sh

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,32 @@ join() {
4141
echo "${out#$sep}"
4242
}
4343

44-
commit="$(dirCommit .)"
44+
for variant in debian alpine; do
45+
commit="$(dirCommit "$variant")"
4546

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 }')"
4748

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-/}" )
5461

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

update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ current="$(
1212
)"
1313

1414
set -x
15-
sed -ri 's/^(ENV GHOST_VERSION) .*/\1 '"$current"'/' Dockerfile
15+
sed -ri 's/^(ENV GHOST_VERSION) .*/\1 '"$current"'/' */Dockerfile

0 commit comments

Comments
 (0)