以下の手順で、Mezzanineのコンテナを構築・実行します。
○構築方法
1. Mezzanineイメージの作成(Dockerfileがあるフォルダで実行)
docker build -t mezzanine .
Dockerfile
FROM python:3.6-alpine3.7
RUN mkdir -p /opt/mezzanine
WORKDIR /opt/mezzanine
RUN apk update \
&& apk add --no-cache --virtual=build-deps jpeg jpeg-dev zlib-dev musl-dev gcc mariadb-dev build-base \
&& pip install mezzanine \
&& pip install mysqlclient \
&& apk del mariadb-dev build-base build-deps gcc \
&& apk add mariadb-client mariadb-client-libs \
&& rm -rf /var/cache/apk/* \
&& mezzanine-project mysite \
&& echo $'#!/bin/sh \n\
until mysql -h db -u root -pmezzanine mezzanine\n\
do \n\
echo -n "." \n\
sleep 1 \n\
done \n\
cd /opt/mezzanine/mysite \n\
sed -i -e \'s/"ENGINE": "django.db.backends.sqlite3",/"ENGINE": "django.db.backends.mysql",/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
sed -i -e \'s/"NAME": "dev.db",/"NAME": "mezzanine",/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
sed -i -e \'s/"USER": "",/"USER": "root",/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
sed -i -e \'s/"PASSWORD": "",/"PASSWORD": "mezzanine",/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
sed -i -e \'s/"HOST": "",/"HOST": "db",/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
sed -i -e \'s/"PORT": "",/"PORT": "3306",/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
sed -i -e \'s/# ALLOWED_HOSTS = \[""\]/ALLOWED_HOSTS = ["*"]/\' /opt/mezzanine/mysite/mysite/local_settings.py \n\
python manage.py createdb --noinput \n\
python manage.py migrate --noinput \n\
python manage.py runserver 0.0.0.0:80' > /opt/mezzanine/mysite/start.sh \
&& chmod +x /opt/mezzanine/mysite/start.sh
EXPOSE 80
VOLUME /opt/mezzanine/mysite
CMD ["/opt/mezzanine/mysite/start.sh"]
2. MezzanineとMySQLコンテナの構築・実行(docker-compose.ymlがあるフォルダで実行)
docker-compose up -d
docker-compose.yml
version: "2"
services:
db:
image: mysql:5.7
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
container_name: "mezzanine-db"
volumes:
- "db-data:/var/lib/mysql"
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: mezzanine
MYSQL_ROOT_PASSWORD: mezzanine
mezzanine:
image: mezzanine
container_name: "mezzanine"
volumes:
- "mezzanine-data:/opt/mezzanine/mysite"
ports:
- "80:80"
depends_on:
- db
volumes:
db-data:
driver: local
mezzanine-data:
driver: local
○Mezzanineの画面
※デフォルトユーザとパスワードはadmin/defaultです。
ありがとう
返信削除応援してるで
ありがとうございます!
削除