Dockerfile
This commit is contained in:
parent
ac7ec124c8
commit
b9c7a14747
|
@ -9,3 +9,8 @@ python3 setup.py install
|
|||
imghost
|
||||
|
||||
Then visit http://127.0.0.1:3000/
|
||||
|
||||
Dockerfile, based on http://gitlab.davepedu.com/dave/docker-nginx:
|
||||
|
||||
# docker build -t imghost -f docker/Dockerfile .
|
||||
# docker run -it --rm -v /host/path:/usr/share/imghost/ui/i/ -p 8080:80 --name imghost imghost
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
FROM dpedu/nginx
|
||||
|
||||
RUN apt-get update ; \
|
||||
apt-get install -y supervisor python3-pip python3-setuptools
|
||||
|
||||
ADD . /usr/share/imghost/
|
||||
|
||||
RUN cd /usr/share/imghost ;\
|
||||
pip3 install -r requirements.txt ;\
|
||||
python3 setup.py install ;\
|
||||
rm -rf scenv README.txt build dist docker imghost imghost.egg-info requirements.txt setup.py ui/i/* .git ; \
|
||||
chown www-data /usr/share/imghost/ui/i
|
||||
|
||||
ADD docker/supervisor-imghost.conf /etc/supervisor/conf.d/imghost.conf
|
||||
ADD docker/default /etc/nginx/sites-enabled/default
|
||||
|
||||
# WORKDIR /usr/share/imghost
|
|
@ -0,0 +1,24 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server ipv6only=on;
|
||||
|
||||
root /usr/share/imghost/ui/;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
#error_page 500 502 503 504 /50x.html;
|
||||
|
||||
#location = /50x.html {
|
||||
# root /usr/share/nginx/html;
|
||||
#}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
[program:imghost]
|
||||
command=/usr/local/bin/imghost
|
||||
autorestart=true
|
||||
directory=/usr/share/imghost
|
||||
user=www-data
|
|
@ -73,7 +73,8 @@ class ImgHostApiV1(Mountable):
|
|||
sha = sha.decode("UTF-8").split(" ")[0]
|
||||
imgpath = os.path.join("i", "{}.{}".format(sha[0:8], ext))
|
||||
os.link(theFile.file.name, os.path.join("ui", imgpath))
|
||||
raise cherrypy.HTTPRedirect("/" + imgpath)
|
||||
cherrypy.response.headers['Location'] = "/" + imgpath
|
||||
cherrypy.response.status = 302
|
||||
|
||||
|
||||
class ImgHostApi(object):
|
||||
|
@ -83,9 +84,11 @@ class ImgHostApi(object):
|
|||
self.ui = Mountable(conf={'/': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': ui_path,
|
||||
'tools.staticdir.index': 'index.html'}}).mount('/')
|
||||
'tools.staticdir.index': 'index.html'
|
||||
}}).mount('/')
|
||||
|
||||
self.app_v1 = ImgHostApiV1().mount('/api/v1')
|
||||
self.app_v1 = ImgHostApiV1(conf={'/': {'tools.proxy.on': True,
|
||||
}}).mount('/api/v1')
|
||||
|
||||
cherrypy.config.update({
|
||||
'sessionFilter.on': False,
|
||||
|
@ -98,7 +101,8 @@ class ImgHostApi(object):
|
|||
'server.socket_host': '0.0.0.0',
|
||||
'server.socket_timeout': 5,
|
||||
'log.screen': False,
|
||||
'engine.autoreload.on': False
|
||||
'engine.autoreload.on': False,
|
||||
|
||||
})
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -1,11 +1,2 @@
|
|||
appdirs==1.4.0
|
||||
cheroot==5.1.0
|
||||
CherryPy==10.0.0
|
||||
imghost==0.0.0
|
||||
packaging==16.8
|
||||
pkg-resources==0.0.0
|
||||
portend==1.8
|
||||
pyparsing==2.1.10
|
||||
pytz==2016.10
|
||||
six==1.10.0
|
||||
tempora==1.6.1
|
||||
|
|
Loading…
Reference in New Issue