Skip to content

Commit

Permalink
Merge pull request #104 from getty708/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
getty708-review authored Jul 4, 2021
2 parents 5383d96 + f85a8e3 commit 90c68d8
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 151 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Publication management system for your lab.

## Full Document

[Document](https://getty708.github.io/PubZ/mkdocs/site/)
[Document](https://getty708.github.io/PubZ/)

## Requirements

Expand Down Expand Up @@ -91,7 +91,7 @@ $ mkdocs serve

### Step.4 Check website

With this setup, we launched 4 containers. You can access to 3 of them with your browser.
With this setup, we launched 3 containers. You can access to 3 of them with your browser.

| App | URL |
|------------|------------------|
Expand Down
42 changes: 0 additions & 42 deletions deploy/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions deploy/django-uwsgi-nginx/app/requirements.txt

This file was deleted.

38 changes: 0 additions & 38 deletions deploy/docker-compose.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions docker-compose-prd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Docker Compose for Production Mode
version: '3'
services:
db:
image: mysql:5.7
container_name: pubz-db-prd
ports:
- "3306:3306"
hostname: db
environment:
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
volumes:
- storage-prd:/var/lib/mysql
- ./docker/mysql:/etc/mysql/conf.d
web:
build:
context: ./
dockerfile: ./docker/django-uwsgi-nginx/Dockerfile
image: pubz:prd-v${PUBZ_VERSION}
container_name: pubz-web-prd-v${PUBZ_VERSION}
hostname: pubz-web-prd
environment:
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
MYSQL_HOST: pubz-db-prd
DJANGO_SECRET_KEY: $DJANGO_SECRET_KEY
VIRTUAL_HOST: $VIRTUAL_HOST
ports:
- '80:8080'
depends_on:
- db

volumes:
storage-prd:
driver: local
driver_opts:
type: none
device: $PWD/storage/db/data/
o: bind
17 changes: 11 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ version: '3'
services:
db:
image: mysql:5.7
container_name: pubz-db-dev-v${PUBZ_VERSION}
ports:
- "3306:3306" # <-これがないと外からアクセス出来ない
hostname: db
container_name: pubz-db-dev
environment:
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
volumes:
- dev-storage:/var/lib/mysql
- storage-dev:/var/lib/mysql
- ./docker/mysql:/etc/mysql/conf.d
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: pubz-phpmyadmin-dev
environment:
PMA_ARBITRARY: 1
PMA_HOST: db
PMA_HOST: pubz-db-dev
PMA_USER: root
PMA_PASSWORD: docker
links:
Expand All @@ -28,13 +30,16 @@ services:
build:
context: ./
dockerfile: ./docker/django/Dockerfile
image: pubz:dev-v${PUBZ_VERSION}
container_name: pubz-web-dev-v${PUBZ_VERSION}
# command: python /code/app/manage.py runserver 0.0.0.0:8000
hostname: django
image: pubz:prd-v${PUBZ_VERSION}
container_name: pubz-web-dev
environment:
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
MYSQL_HOST: db
MYSQL_HOST: pubz-db-dev
DJANGO_SECRET_KEY: $DJANGO_SECRET_KEY
volumes:
- ./src:/code
Expand All @@ -48,7 +53,7 @@ services:
tty: true

volumes:
dev-storage:
storage-dev:
driver: local
driver_opts:
type: none
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,60 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:18.04
# == Stage.1: Make requirements.txt by poetry ==
FROM python:3.9-slim as builder
WORKDIR /root/src/
RUN pip install poetry
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt > requirements.txt

MAINTAINER Dockerfiles

# == Stage.3: Build Minimum Images ==
FROM ubuntu:18.04

# timezone setting
RUN DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata
# timezone setting
ENV TZ=Asia/Tokyo


# Install required packages and remove the apt packages cache when done.

RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
git \
vim \
python3 \
python3-dev \
python3-setuptools \
python3-pip \
nginx \
supervisor \
sqlite3 && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install emacs -y
RUN apt-get update && apt-get install python-pip -y
RUN pip install --upgrade pip && \
pip3 install -U pip setuptools

default-libmysqlclient-dev \
emacs \
git \
mysql-client \
nginx \
supervisor \
&& rm -rf /var/lib/apt/lists/*
# Install Python3.8
RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
software-properties-common \
&& add-apt-repository -y ppa:deadsnakes \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3.8-venv \
libpython3.8-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& :
RUN python3.8 -m venv /venv
ENV PATH=/venv/bin:$PATH
RUN apt-get update \
&& apt-get install -y \
python-pip \
python3-pip \
&& pip install --upgrade pip \
&& pip3 install -U pip setuptools

# encode setting
# set the locale
RUN apt-get clean && apt-get update && apt-get install -y locales
RUN apt-get clean \
&& apt-get update \
&& apt-get install -y locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
Expand All @@ -63,25 +81,20 @@ RUN pip3 install uwsgi
RUN echo "daemon off;" >> /etc/nginx/nginx.conf


COPY nginx-app.conf /etc/nginx/sites-available/default
COPY supervisor-app.conf /etc/supervisor/conf.d/
COPY ./docker/django-uwsgi-nginx/nginx-app.conf /etc/nginx/sites-available/default
COPY ./docker/django-uwsgi-nginx/supervisor-app.conf /etc/supervisor/conf.d/

# COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
# to prevent re-installing (all your) dependencies when you made a change a line or two in your app.

COPY app/requirements.txt /code/app/
RUN apt-get update && apt-get install -y \
mysql-client \
python-dev \
default-libmysqlclient-dev
RUN pip3 install -r /code/app/requirements.txt
RUN pip3 install PyMySQL
COPY --from=builder /root/src/requirements.txt .
RUN pip3 install -r requirements.txt --no-deps

# add (the rest of) our code
COPY . /code/
COPY ./src /code/

# ENV PYTHONPATH /usr/bin/python3

ENV PYTHONPATH /usr/bin/python3

# install django, normally you would remove this step because your project would already
# be installed in the code/app/ directory
Expand Down
6 changes: 6 additions & 0 deletions docker/django-uwsgi-nginx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Django, uWSGI and Nginx in a container, using Supervisord

## References

- [GitHub: darron/django-uwsgi-nginx](https://github.com/darron/django-uwsgi-nginx)
- [GitHub: sleepless-se/django-uwsgi-nginx-https](https://github.com/sleepless-se/django-uwsgi-nginx-https)
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions docker/django/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
poetry.lock
pyproject.toml
10 changes: 10 additions & 0 deletions docker/django/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PUBZ_VERSION := 0.5.0


help:
@echo If you cannot build image with docker-compose, build container by `make build.`

build:
cp ../../pyproject.toml .
cp ../../poetry.lock .
docker build -t pubz:dev-v${PUBZ_VERSION} .
Loading

0 comments on commit 90c68d8

Please sign in to comment.