Skip to content

Add initial alpine variant #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2017
Merged

Conversation

tianon
Copy link
Member

@tianon tianon commented Dec 21, 2016

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
Copy link
Member Author

tianon commented Dec 21, 2016

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
Copy link
Member Author

tianon commented Dec 21, 2016

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

@yosifkit
Copy link
Member

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

@tianon
Copy link
Member Author

tianon commented Dec 28, 2016

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

@tianon
Copy link
Member Author

tianon commented Dec 28, 2016

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

@pascalandy
Copy link
Contributor

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

@tianon
Copy link
Member Author

tianon commented Apr 6, 2017

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
Copy link
Member Author

tianon commented Apr 6, 2017

Updated diff, for reference:

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 docker-library: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 (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