-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build docker dev env based on Linux alpine
- Loading branch information
Gregory Igelmund
committed
Mar 23, 2017
1 parent
708df82
commit 2a79283
Showing
5 changed files
with
71 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
chown mailpile: /mailpile-data/ -R | ||
|
||
su-exec mailpile "$@" |