using multistage dockerfile
This commit is contained in:
parent
27ae28acef
commit
6689d85e08
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
PY?=/usr/bin/python3
|
||||
PY?=/usr/local/bin/python3
|
||||
PELICAN?=pelican
|
||||
PELICANOPTS=
|
||||
|
||||
|
44
builder/Dockerfile
Normal file
44
builder/Dockerfile
Normal file
@ -0,0 +1,44 @@
|
||||
FROM python:3.7.3-alpine3.9 as base
|
||||
ENV LANG C.UTF-8
|
||||
ENV SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
|
||||
ENV BLOG_UID 1000
|
||||
ENV BLOG_GID 1000
|
||||
RUN set -ex \
|
||||
&& echo "http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
|
||||
&& apk upgrade -a --no-cache \
|
||||
&& apk add --no-cache \
|
||||
lftp \
|
||||
make \
|
||||
tzdata \
|
||||
&& cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
|
||||
&& echo "Europe/Berlin" > /etc/timezone \
|
||||
&& apk del tzdata \
|
||||
&& addgroup -g $BLOG_GID blog \
|
||||
&& adduser -h /home/blog -D -s /bin/sh -G blog blog \
|
||||
&& chown -R $BLOG_UID:$BLOG_GID /home/blog
|
||||
COPY requirements.txt .
|
||||
|
||||
FROM base as builder
|
||||
RUN set -ex \
|
||||
&& apk add --no-cache\
|
||||
ca-certificates \
|
||||
g++ \
|
||||
git \
|
||||
ca-certificates \
|
||||
cython \
|
||||
gcc \
|
||||
git \
|
||||
linux-headers \
|
||||
make \
|
||||
musl-dev \
|
||||
&& pip install -r requirements.txt
|
||||
|
||||
FROM base
|
||||
COPY --from=builder /root/.cache /root/.cache
|
||||
RUN set -ex \
|
||||
&& pip install -r requirements.txt \
|
||||
&& rm -rf /root/.cache \
|
||||
&& rm requirements.txt
|
||||
USER blog
|
||||
WORKDIR /blog
|
||||
EXPOSE 8000
|
11
builder/requirements.txt
Normal file
11
builder/requirements.txt
Normal file
@ -0,0 +1,11 @@
|
||||
beautifulsoup4
|
||||
cookiecutter==1.4.0
|
||||
flickr2markdown
|
||||
ipython>=4.0
|
||||
jinja2-slug
|
||||
jupyter>=1.0
|
||||
markdown
|
||||
nbconvert>=4.0
|
||||
pelican==4.0.1
|
||||
typogrify
|
||||
tzlocal
|
@ -1,7 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
blog:
|
||||
build: writing_env/
|
||||
build: builder/
|
||||
image: xsteadfastx/blog
|
||||
container_name: blog
|
||||
environment:
|
||||
|
@ -1,44 +0,0 @@
|
||||
FROM alpine:3.9
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
ENV BLOG_UID 1000
|
||||
ENV BLOG_GID 1000
|
||||
|
||||
# prepare repositories
|
||||
RUN set -ex \
|
||||
&& echo "http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
|
||||
&& apk update
|
||||
|
||||
# add files
|
||||
ADD root /
|
||||
|
||||
# prepare for provisioning
|
||||
RUN set -ex \
|
||||
&& apk upgrade -a --no-cache \
|
||||
&& apk add --no-cache\
|
||||
ansible \
|
||||
bash \
|
||||
ca-certificates \
|
||||
g++ \
|
||||
git \
|
||||
openssh \
|
||||
python \
|
||||
sudo \
|
||||
&& addgroup -g $BLOG_GID blog \
|
||||
&& adduser -h /home/blog -D -s /bin/sh -G blog blog \
|
||||
&& echo 'blog ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/blog \
|
||||
&& chmod 0440 /etc/sudoers.d/blog \
|
||||
&& chown -R $BLOG_UID:$BLOG_GID /home/blog
|
||||
|
||||
# switch user to blog
|
||||
USER blog
|
||||
|
||||
# provision
|
||||
RUN set -ex \
|
||||
&& ansible-playbook -c local /home/blog/playbooks/writing_env.yml
|
||||
|
||||
WORKDIR /blog
|
||||
|
||||
EXPOSE 8000
|
@ -1,6 +0,0 @@
|
||||
[API]
|
||||
key = 2207902126a225122e46533e82b6a947
|
||||
|
||||
[Defaults]
|
||||
user = marvinxsteadfast
|
||||
size = large
|
@ -1,75 +0,0 @@
|
||||
# vim:ft=ansible
|
||||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local
|
||||
|
||||
tasks:
|
||||
|
||||
- name: install deps
|
||||
apk:
|
||||
state: present
|
||||
update_cache: true
|
||||
name:
|
||||
- ack
|
||||
- ansible
|
||||
- bash-completion
|
||||
- ca-certificates
|
||||
- coreutils
|
||||
- curl
|
||||
- cython
|
||||
- gcc
|
||||
- git
|
||||
- grep
|
||||
- imagemagick
|
||||
- lftp
|
||||
- linux-headers
|
||||
- make
|
||||
- musl-dev
|
||||
- nodejs
|
||||
- python3
|
||||
- python3-dev
|
||||
- wget
|
||||
become: yes
|
||||
|
||||
- name: pip status
|
||||
stat:
|
||||
path=/usr/bin/pip
|
||||
register: pip
|
||||
|
||||
- name: install pip
|
||||
shell: curl https://bootstrap.pypa.io/get-pip.py | python3
|
||||
become: yes
|
||||
when: pip.stat.exists == False
|
||||
|
||||
- name: install pip packages
|
||||
pip:
|
||||
executable: pip3
|
||||
name:
|
||||
- beautifulsoup4
|
||||
- cookiecutter==1.4.0
|
||||
- flickr2markdown
|
||||
- ipython>=4.0
|
||||
- jinja2-slug
|
||||
- jupyter>=1.0
|
||||
- markdown
|
||||
- nbconvert>=4.0
|
||||
- pelican==4.0.1
|
||||
- typogrify
|
||||
- tzlocal
|
||||
- virtualenv
|
||||
become: yes
|
||||
|
||||
- name: add flickr2markdown config
|
||||
copy:
|
||||
src=flickr2markdown
|
||||
dest=~/.flickr2markdown
|
||||
|
||||
- name: set timezone
|
||||
copy:
|
||||
content="Europe/Berlin"
|
||||
dest=/etc/timezone
|
||||
owner=root
|
||||
group=root
|
||||
mode=0644
|
||||
backup=yes
|
||||
become: yes
|
Loading…
Reference in New Issue
Block a user