Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
Created January 28, 2016 13:23
Show Gist options
  • Save AlecTaylor/d69ce4d41d6e036f89f2 to your computer and use it in GitHub Desktop.
Save AlecTaylor/d69ce4d41d6e036f89f2 to your computer and use it in GitHub Desktop.
FROM alpine:3.3
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN addgroup -S mongodb && adduser -S -G mongodb mongodb
RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories \
&& apk update \
&& apk add openrc \
&& apk add mongodb@testing
RUN mkdir -p /data/db && chown -R mongodb:mongodb /data
VOLUME /data
WORKDIR /data
# See https://docs.mongodb.org/manual/reference/default-mongodb-port/
EXPOSE 27017
EXPOSE 28017
RUN printf "#!/usr/bin/env sh\nrc-service mongodb start" >> /tmp/start_mongodb.sh && chmod +x /tmp/start_mongodb.sh
CMD [ "/tmp/start_mongodb.sh" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment