merge Dockerfile

This commit is contained in:
pycook 2019-11-12 10:40:37 +08:00
parent 79a19d4b49
commit 62b56da0d8
3 changed files with 34 additions and 24 deletions

30
Dockerfile Normal file
View File

@ -0,0 +1,30 @@
# ================================= UI ================================
FROM exiasr/alpine-yarn-nginx AS cmdb-ui
LABEL description="cmdb-ui"
COPY ui /data/apps/cmdb-ui
WORKDIR /data/apps/cmdb-ui
RUN sed -i "s#http://127.0.0.1:5000##g" .env && yarn install && yarn build \
&& mkdir /etc/nginx/html && cp -r dist/* /etc/nginx/html && rm -f /etc/nginx/conf.d/default.conf
# ================================= API ================================
FROM centos:7.6.1810 AS cmdb-api
LABEL description="Python2.7.5,cmdb"
COPY . /data/apps/cmdb
WORKDIR /data/apps/cmdb
RUN yum install -y epel-release && yum clean all \
&& yum install -y python-pip \
&& pip install --no-cache-dir -r docs/requirements.txt \
&& cp ./api/settings.py.example ./api/settings.py \
&& sed -i "s#{user}:{password}@127.0.0.1:3306/{db}#cmdb:123456@mysql:3306/cmdb#g" api/settings.py \
&& sed -i "s/127.0.0.1/redis/g" api/settings.py
CMD ["bash", "-c", "flask run"]

View File

@ -1,20 +0,0 @@
# build under cmdb directory other than api
# maybe use: cd ..
FROM centos:7.6.1810 AS cmdb-api
LABEL description="Python2.7.5,cmdb"
RUN mkdir -p /data/apps/cmdb /data/apps/cmdb/logs
COPY . /data/apps/cmdb
WORKDIR /data/apps/cmdb
RUN yum install -y epel-release && yum clean all\
&& yum install -y python-pip \
&& pip install --no-cache-dir -r docs/requirements.txt \
&& cp ./api/settings.py.example ./api/settings.py \
&& sed -i "s#{user}:{password}@127.0.0.1:3306/{db}#cmdb:123456@mysql:3306/cmdb#g" api/settings.py \
&& sed -i "s/127.0.0.1/redis/g" api/settings.py
CMD ["bash", "-c", "flask run"]

View File

@ -1,4 +1,4 @@
version: '3.4'
version: '3.5'
services:
cmdb-db:
@ -29,7 +29,7 @@ services:
cmdb-api:
build:
context: .
dockerfile: api/Dockerfile
target: cmdb-api
image: cmdb-api:0.1
container_name: cmdb-api
environment:
@ -51,8 +51,8 @@ services:
cmdb-ui:
build:
context: ./ui
dockerfile: Dockerfile
context: .
target: cmdb-ui
image: cmdb-ui:0.1
container_name: cmdb-ui
depends_on: