Skip to content

Add initial alpine variant - #55

Merged
yosifkit merged 1 commit into
TryGhost:masterfrom
infosiftr:alpine
Apr 6, 2017
Merged

yosifkit merged 1 commit into
TryGhost:masterfrom
infosiftr:alpine

Conversation

@tianon

@tianon tianon commented Dec 21, 2016

Copy link
Copy Markdown
Contributor

Closes #46

ghost               alpine              5515e85f092c        36 seconds ago      167.1 MB
ghost               debian              5ec60b9680ff        7 minutes ago       333.8 MB
diff --git a/debian/Dockerfile b/alpine/Dockerfile
index 91d2012..caee2fd 100644
--- a/debian/Dockerfile
+++ b/alpine/Dockerfile
@@ -1,53 +1,53 @@
 # http://support.ghost.org/supported-node-versions/
 # https://github.com/nodejs/LTS
-FROM node:4-slim
-
-RUN groupadd user && useradd --create-home --home-dir /home/user -g user user
-
-# grab gosu for easy step-down from root
-ENV GOSU_VERSION 1.7
-RUN set -x \
-	&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
-	&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
-	&& export GNUPGHOME="$(mktemp -d)" \
-	&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
-	&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
-	&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
-	&& chmod +x /usr/local/bin/gosu \
-	&& gosu nobody true
+FROM node:4-alpine
+
+# grab su-exec for easy step-down from root
+RUN apk add --no-cache 'su-exec>=0.2'
+
+RUN apk add --no-cache \
+# add "bash" for "[["
+		bash \
+# add "tar" for "--one-file-system"
+		tar
 
 ENV GHOST_SOURCE /usr/src/ghost
 WORKDIR $GHOST_SOURCE
 
 ENV GHOST_VERSION 0.11.3
 
-RUN buildDeps=' \
+RUN set -ex; \
+	apk add --no-cache --virtual .build-deps \
+		ca-certificates \
 		gcc \
 		make \
+		openssl \
 		python \
 		unzip \
-	' \
-	&& set -x \
-	&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
-	&& wget -O ghost.zip "https://github.com/TryGhost/Ghost/releases/download/${GHOST_VERSION}/Ghost-${GHOST_VERSION}.zip" \
-	&& unzip ghost.zip \
-	&& npm install --production \
-	&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
-	&& rm ghost.zip \
-	&& npm cache clean \
-	&& rm -rf /tmp/npm*
+	; \
+	\
+	wget -O ghost.zip "https://github.com/TryGhost/Ghost/releases/download/${GHOST_VERSION}/Ghost-${GHOST_VERSION}.zip"; \
+	unzip ghost.zip; \
+	\
+	npm install --production; \
+	\
+	apk del .build-deps; \
+	\
+	rm ghost.zip; \
+	npm cache clean; \
+	rm -rf /tmp/npm*
 
 ENV GHOST_CONTENT /var/lib/ghost
 RUN mkdir -p "$GHOST_CONTENT" \
-	&& chown -R user:user "$GHOST_CONTENT" \
+	&& chown -R node:node "$GHOST_CONTENT" \
 # Ghost expects "config.js" to be in $GHOST_SOURCE, but it's more useful for
 # image users to manage that as part of their $GHOST_CONTENT volume, so we
 # symlink.
 	&& ln -s "$GHOST_CONTENT/config.js" "$GHOST_SOURCE/config.js"
 VOLUME $GHOST_CONTENT
 
-COPY docker-entrypoint.sh /entrypoint.sh
-ENTRYPOINT ["/entrypoint.sh"]
+COPY docker-entrypoint.sh /usr/local/bin/
+ENTRYPOINT ["docker-entrypoint.sh"]
 
 EXPOSE 2368
 CMD ["npm", "start"]
diff --git a/debian/docker-entrypoint.sh b/alpine/docker-entrypoint.sh
index 18f120b..622f014 100755
--- a/debian/docker-entrypoint.sh
+++ b/alpine/docker-entrypoint.sh
@@ -3,8 +3,8 @@ set -e
 
 # allow the container to be started with `--user`
 if [[ "$*" == npm*start* ]] && [ "$(id -u)" = '0' ]; then
-	chown -R user "$GHOST_CONTENT"
-	exec gosu user "$BASH_SOURCE" "$@"
+	chown -R node "$GHOST_CONTENT"
+	exec su-exec node "$BASH_SOURCE" "$@"
 fi
 
 if [[ "$*" == npm*start* ]]; then

@tianon

tianon commented Dec 21, 2016

Copy link
Copy Markdown
Contributor Author

This uses the node user added in nodejs/docker-node#263 rather than creating a new one named user -- would love to switch over the Debian-based image as well, but not sure what the downstream implications of such a change might be. 😕

@tianon

tianon commented Dec 21, 2016

Copy link
Copy Markdown
Contributor Author

The outcome of nodejs/docker-node#289 might put a kink in that as well, though. 😞

@yosifkit

Copy link
Copy Markdown
Contributor

Seems fine to me, but yes to waiting on the node user issue.

@tianon

tianon commented Dec 28, 2016

Copy link
Copy Markdown
Contributor Author

I think nodejs/docker-node#299 is probably pretty firm confirmation on where the Node image maintainers stand. 😄

@tianon

tianon commented Dec 28, 2016

Copy link
Copy Markdown
Contributor Author

Wait, that's actually kind of conflicting. I'm confused now.

@pascalandy

Copy link
Copy Markdown
Contributor

Let me know if I can help to test this :)

@tianon

tianon commented Apr 6, 2017

Copy link
Copy Markdown
Contributor Author

It's been long enough that I think it's really safe to say the Node.js maintainers are committed to keeping the node user -- I've rebased and updated this accordingly (and shrunk the diff more). 😄

I'm debating whether we should switch the debian variant to use the node user as well. 🤔

@tianon

tianon commented Apr 6, 2017

Copy link
Copy Markdown
Contributor Author

Updated diff, for reference:

Details
diff --git a/alpine/Dockerfile b/debian/Dockerfile
index 6583678..eaf2ca8 100644
--- a/alpine/Dockerfile
+++ b/debian/Dockerfile
@@ -1,15 +1,20 @@
 # http://support.ghost.org/supported-node-versions/
 # https://github.com/nodejs/LTS
-FROM node:4-alpine
-
-# grab su-exec for easy step-down from root
-RUN apk add --no-cache 'su-exec>=0.2'
-
-RUN apk add --no-cache \
-# add "bash" for "[["
-		bash \
-# add "tar" for "--one-file-system"
-		tar
+FROM node:4-slim
+
+RUN groupadd user && useradd --create-home --home-dir /home/user -g user user
+
+# grab gosu for easy step-down from root
+ENV GOSU_VERSION 1.7
+RUN set -x \
+	&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
+	&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
+	&& export GNUPGHOME="$(mktemp -d)" \
+	&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
+	&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
+	&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
+	&& chmod +x /usr/local/bin/gosu \
+	&& gosu nobody true
 
 ENV GHOST_SOURCE /usr/src/ghost
 WORKDIR $GHOST_SOURCE
@@ -18,21 +23,22 @@ ENV GHOST_VERSION 0.11.7
 
 RUN set -ex; \
 	\
-	apk add --no-cache --virtual .build-deps \
-		ca-certificates \
+	buildDeps=' \
 		gcc \
 		make \
-		openssl \
 		python \
 		unzip \
-	; \
+	'; \
+	apt-get update; \
+	apt-get install -y $buildDeps --no-install-recommends; \
+	rm -rf /var/lib/apt/lists/*; \
 	\
 	wget -O ghost.zip "https://github.com/TryGhost/Ghost/releases/download/${GHOST_VERSION}/Ghost-${GHOST_VERSION}.zip"; \
 	unzip ghost.zip; \
 	\
 	npm install --production; \
 	\
-	apk del .build-deps; \
+	apt-get purge -y --auto-remove $buildDeps; \
 	\
 	rm ghost.zip; \
 	npm cache clean; \
@@ -40,7 +46,7 @@ RUN set -ex; \
 
 ENV GHOST_CONTENT /var/lib/ghost
 RUN mkdir -p "$GHOST_CONTENT" \
-	&& chown -R node:node "$GHOST_CONTENT" \
+	&& chown -R user:user "$GHOST_CONTENT" \
 # Ghost expects "config.js" to be in $GHOST_SOURCE, but it's more useful for
 # image users to manage that as part of their $GHOST_CONTENT volume, so we
 # symlink.
@@ -48,6 +54,7 @@ RUN mkdir -p "$GHOST_CONTENT" \
 VOLUME $GHOST_CONTENT
 
 COPY docker-entrypoint.sh /usr/local/bin/
+RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
 ENTRYPOINT ["docker-entrypoint.sh"]
 
 EXPOSE 2368

@tianon
tianon requested a review from yosifkit April 6, 2017 21:16
@yosifkit
yosifkit merged commit b174b0b into TryGhost:master Apr 6, 2017
@yosifkit
yosifkit deleted the alpine branch April 6, 2017 21:29
tianon added a commit to infosiftr/stackbrew that referenced this pull request Apr 7, 2017
- `drupal`: 8.3.0 (docker-library/drupal#78), remove 8.2 (docker-library/drupal#80)
- `ghost`: add `alpine` variant (TryGhost/docker-library-ghost#55)
- `mongo`: more edge cases (docker-library/mongo#167, docker-library/mongo#169)
- `postgres`: adjust append (docker-library/postgres#270)
- `rabbitmq`: add `vm_memory_high_watermark` support based on cgroup limits (docker-library/rabbitmq#105)
- `rocket.chat`: 0.55.0-rc.1
- `wordpress`: add `wp-cli` variant (docker-library/wordpress#198)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants