Skip to content

Commit

Permalink
Build docker dev env based on Linux alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Igelmund committed Mar 23, 2017
1 parent 708df82 commit 2a79283
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 49 deletions.
76 changes: 28 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,33 @@
FROM ubuntu:16.10
FROM alpine:3.5

# Install dependencies
RUN apt-get update -y && \
apt-get install -y openssl \
python-pip \
python-imaging \
python-jinja2 \
python-lxml \
libxml2-dev \
libxslt1-dev \
python-pgpdump \
python-cryptography \
spambayes \
tor

# Add mailpile code (required for initial setup, not for develpoment)
ADD . /Mailpile

# Create data dir
# This will be overriden by a volume hosted by the docker host (your dev machine)
RUN mkdir /mailpile-data

# Create mailpile user and group.
RUN groupadd -r mailpile && \
useradd -r -d /mailpile-data -g mailpile mailpile

# Workaround: Setting mailpile users uid to 1000 to have write permissions
# from the docker host the to the shared volumes /Mailpile and /mailpile-data.
# Mounted volumes seem to be configured w/ uid/guid = 1000.
# Learn more here:
# - https://github.com/docker/docker/issues/7198
# - https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
RUN usermod -u 1000 mailpile

# Fix permissions for dirs (w/o they would only be accessible for root)
RUN chown -R mailpile:mailpile /Mailpile
RUN chown -R mailpile:mailpile /mailpile-data

# Set /Mailpile as root dir for further RUN cmds
WORKDIR /Mailpile

RUN pip install --upgrade pip
RUN pip install -r requirements-dev.txt

# Run as mailpile user
USER mailpile

# Initialize mailpile
RUN ./mp setup
# Create users and groups
RUN addgroup -S mailpile && adduser -S -h /mailpile-data -G mailpile mailpile

CMD ["./mp", "--www=0.0.0.0:33411", "--wait"]
# Install dependencies
RUN apk --no-cache add \
ca-certificates \
openssl \
gnupg1 \
py-pip \
py-imaging \
py-jinja2 \
py-lxml \
py-lockfile \
py-pillow \
py-pbr \
py-cryptography \
su-exec

ADD requirements.txt /Mailpile/requirements.txt
RUN pip install -r requirements.txt

# Entrypoint
ADD packages/docker/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ./mp --www=0.0.0.0:33411 --wait
EXPOSE 33411

# Add code
ADD . /Mailpile
22 changes: 22 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM mailpile

# Install C compiler for python deps w/ native extensions
RUN apk --no-cache add \
gcc \
libc-dev \
python-dev \
shadow

# Workaround: Setting mailpile users uid to 1000 to have write permissions
# from the docker host the to the shared volumes /Mailpile and /mailpile-data.
# Mounted volumes seem to be configured w/ uid/guid = 1000.
# Learn more here:
# - https://github.com/docker/docker/issues/7198
# - https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
RUN usermod -u 1000 mailpile

RUN pip install -r requirements-dev.txt

RUN chmod +x /entrypoint.sh

CMD ["./mp", "--www=0.0.0.0:33411", "--wait"]
14 changes: 14 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.0'
services:
mailpile_dev:
container_name: mailpile_dev
build:
context: .
dockerfile: Dockerfile.dev
image: mailpile_dev
volumes:
- .:/Mailpile
- .dev-mailpile-data:/mailpile-data:rw
ports:
- 33411:33411

3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: '3.0'
services:
mailpile:
container_name: mailpile_dev
container_name: mailpile
build: .
image: mailpile
volumes:
- .:/Mailpile
- .dev-mailpile-data:/mailpile-data
Expand Down
5 changes: 5 additions & 0 deletions packages/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

chown mailpile: /mailpile-data/ -R

su-exec mailpile "$@"

0 comments on commit 2a79283

Please sign in to comment.