瀏覽代碼

Resolve "Dockerfile"

Eric Tröbs 4 年之前
父節點
當前提交
1259a4330a
共有 3 個文件被更改,包括 101 次插入14 次删除
  1. 9 0
      .dockerignore
  2. 49 0
      Dockerfile
  3. 43 14
      README.md

+ 9 - 0
.dockerignore

@@ -0,0 +1,9 @@
+env/
+venv/
+webui/node_modules/
+projects/
+
+*.sqlite
+*.sqlite-journal
+*.sqlite3
+*.sqlite3-journal

+ 49 - 0
Dockerfile

@@ -0,0 +1,49 @@
+########################################
+# build webui                          #
+########################################
+FROM node:14 AS builder
+
+# copy files
+COPY models/        /pycs/models/
+COPY labels/        /pycs/labels/
+COPY pycs/          /pycs/pycs/
+COPY webui/         /pycs/webui_dev/
+COPY app.py         /pycs/
+COPY settings.json  /pycs/
+
+# install packages
+RUN cd /pycs/webui_dev/  \
+ && npm install
+
+# build webui
+RUN cd /pycs/webui_dev/  \
+ && npm run build
+
+# move dist folder to webui
+RUN cd /pycs/                  \
+ && mv webui_dev/dist/ webui/  \
+ && rm -rf webui_dev/
+
+
+########################################
+# build pycs image                     #
+########################################
+FROM python:3.9
+
+# copy from builder
+COPY --from=builder /pycs/ /pycs/
+
+# install required libraries for opencv
+RUN apt-get update \
+ && apt-get install -y libgl1-mesa-glx ffmpeg libsm6 libxext6
+
+# create venv and install dependencies
+RUN cd /pycs/                                                 \
+  && python -m venv venv                                      \
+  && ./venv/bin/pip install numpy opencv-python Pillow scipy  \
+  && ./venv/bin/pip install eventlet flask python-socketio
+
+# configure start
+EXPOSE     5000
+WORKDIR    /pycs/
+ENTRYPOINT ["./venv/bin/python", "app.py"]

+ 43 - 14
README.md

@@ -1,53 +1,82 @@
 # PyCS
-
 [![pipeline status](https://gitlab.com/troebs/pycs/badges/master/pipeline.svg)](https://gitlab.com/troebs/pycs/-/commits/master)
 [![coverage report](https://gitlab.com/troebs/pycs/badges/master/coverage.svg)](https://gitlab.com/troebs/pycs/-/commits/master)
 [![made-with-python](https://img.shields.io/badge/Made%20with-Python-3c80ba.svg)](https://www.python.org/)
 [![made-with-vuejs](https://img.shields.io/badge/Made%20with-Vue.js-62b45b.svg)](https://vuejs.org/)
 
-PyCS is a python tool to use and update machine learning models using any modern web browser.
+PyCS is a python tool to use and fit machine learning models using any modern web browser.
 
-## Requirements
 
+## Requirements
 - python 3.6 + pip
 - nodejs 14 + npm
 
-## Getting Started
 
-create and activate a virtual python environment
+## Getting Started
+### CI Builds
+Download the [latest version](https://gitlab.com/troebs/pycs/-/jobs/artifacts/master/download?job=bundle) and unzip it. Execute the following commands using a command prompt:
 
+- create and activate a virtual python environment
 ```bash
 python -m venv env
 source env/bin/activate
 ```
 
-install python dependencies
-
+- install python dependencies
 ```bash
 pip install numpy opencv-python Pillow scipy
 pip install eventlet flask python-socketio
 ```
 
-start server
-
+- start server
 ```bash
 python app.py
 ```
 
-change directory to webui
+### Docker
+Docker is the preferred way to quickly start a PyCS instance without requiring any more software or libraries on your system.
 
+- build image with tag `pycs`
 ```bash
-cd webui/
+docker build -t pycs .
+```
+
+- start container
+```bash
+docker run -p 5000:5000 pycs
+```
+
+### Development
+Use `git` to clone this repository or download the [latest version as a zip file](https://gitlab.com/troebs/pycs/-/archive/master/pycs-master.zip). Execute the following commands using a command prompt:
+
+- create and activate a virtual python environment
+```bash
+python -m venv env
+source env/bin/activate
+```
+
+- install python dependencies
+```bash
+pip install numpy opencv-python Pillow scipy
+pip install eventlet flask python-socketio
 ```
 
-install vuejs
+- start server
+```bash
+python app.py
+```
 
+- change directory to webui
 ```bash
-npm install vue
+cd webui/
 ```
 
-start frontend
+- install vuejs and other dependencies
+```bash
+npm install
+```
 
+- start frontend
 ```bash
 npm run serve
 ```