Skip to content

Commit

Permalink
Merge pull request #30 from brondsem/vagrant_docker
Browse files Browse the repository at this point in the history
Convert vagrant to docker
  • Loading branch information
brondsem authored Jan 4, 2025
2 parents 843a17e + 3e9dc42 commit 1e6a2ba
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 166 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
data
*.pyc
*.pyo
.vagrant/
.idea/
.idea/
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Bionic
FROM ubuntu:18.04

ENV DEBIAN_FRONTEND=noninteractive

ENV BASE=/opt/waznexserver
ENV CODE=$BASE/WaznexServer
ENV VENV=$BASE/env
ENV PIP=$VENV/bin/pip
ENV PYTHON=$VENV/bin/python

RUN mkdir $BASE

RUN apt-get update
RUN apt-get install -y nginx python-dev libjpeg62 libjpeg-dev libfreetype6 libfreetype6-dev libtiff5 libtiff5-dev libwebp6 libwebp-dev zlib1g-dev run-one
RUN apt-get install -y curl \
&& curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python \
&& pip --version
RUN pip install -U pip
RUN python -m pip install -U virtualenv
RUN virtualenv -p python2.7 $VENV

WORKDIR $CODE

COPY ./requirements.txt $CODE/
RUN $PIP install -r requirements.txt

COPY . $CODE

ENV PATH=$VENV/bin:$PATH

RUN waznexserver/utils.py # inits data

EXPOSE 8080

# using array for CMD avoids shell intermediary, so that Ctrl-C works
RUN chmod +x waznexserver/waznexserver.py
CMD ["waznexserver/waznexserver.py"]
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,19 @@ run_production:
sudo service waznexserver restart
sudo service waznex-process-grid restart
sudo service nginx restart

DOCKER_BUILD := docker build --platform linux/amd64 -t waznexserver .

.PHONY: docker_build
docker_build:
$(DOCKER_BUILD)

.PHONY: docker_dev
docker_dev:
# (re)builds the latest image and runs it
docker run --rm --platform linux/amd64 -p 8080:8080 -it $(shell $(DOCKER_BUILD) -q)

.PHONY: docker_dev_process
docker_dev_process:
# connects to existing docker_dev and runs the processing script
docker exec -it $(shell docker ps -q --filter ancestor=waznexserver) waznexserver/process_grid.py
109 changes: 49 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,18 @@ and the server converts this into an interactive grid:

This allows attendees to see what's going on in upcoming sessions without going out to the lobby.

Waznex Server is based on the Flask microframework and can easily be hosted on a Linux or OSX server. I currently recommend running in production on an Ubuntu 18.04 with at least 1GB of RAM.
Waznex Server is based on the Flask microframework and can easily be hosted on a Linux or OSX server. I currently recommend running in production on Ubuntu with at least 1GB of RAM.

## Version 0.7 ##

- responsive full width display
- UI & wording updates
- show relative time since photo uploaded
- caching headers for static files
- auto-rotate iphone images
- system service for splitting the grid
- jinja loop fix
- pip/python2 bootstrap fix

## Version 0.6 ##

- Upgraded to Ubuntu 18.04 Bionic

## Version 0.5 ##

- Switched install from upstart to systemd for Ubuntu 16.04
- Moved to sockets for nginx to waznexserver communication

## Version 0.4 ##

- Added Vagrant for easier development
- Much improved Makefile for easier development and production installation
- Usable documentation

## Version 0.3 ##

- Newer versions of Flask and dependencies.
- Diagnostic image link between sizes and mark bad.
- Mark bad button.

## Version 0.2 ##

- It now has a database backend using SQLAlchemy instead of the thread-unsafe global list. This has only been tested with Sqlite so far.
- You can now control how many images are shown on the main page - it's no longer hard-coded to 3.

## Version 0.1 ##

- Version 0.1 includes the bare essentials of a working server.
- It can accept file uploads and will display the three most recent uploads using the mobile web theme.
- It generates two additional sized versions of each photo: a downsized version with maximum size of 1024x1024 pixels, and a thumbnail version with a maximum size of 316x316 pixels. The downsized version is useful for viewing on mobile platforms that limit download size (WebOS). The thumbnail version is sized to fit the mobile theme width.

# Installation

## Development

1. Install Vagrant and a provider (VirtualBox)
2. Install git
3. `git clone https://github.com/brousch/WaznexServer.git`
4. `cd WaznexServer`
5. `vagrant up`
6. `vagrant ssh`
1. Install Docker and git
2. `git clone https://github.com/brousch/WaznexServer.git`
3. `cd WaznexServer`
4. `make docker_dev` (or run Docker commands from Makefile manually)
5. Ctrl-C to stop it. Re-run it if you make file changes (no shared volumes currently)

## Production on Ubuntu 18.04 64bit

Expand Down Expand Up @@ -95,10 +52,8 @@ Waznex Server is based on the Flask microframework and can easily be hosted on a

## Development

1. `vagrant ssh`
2. `cd /opt/waznexserver/Waznexserver`
3. `make run`
4. Run `waznexserver/process_grid.py` after uploading
1. `make docker_run` or run waznexserver.py in your own Python environment
2. after uploading a file `make docker_dev_process` or process_grid.py

## Production

Expand All @@ -108,13 +63,47 @@ Waznex Server is based on the Flask microframework and can easily be hosted on a
4. Set up HTTPS e.g. https://www.linode.com/docs/guides/enabling-https-using-certbot-with-nginx-on-ubuntu
5. Set up HTTP/2 (just append `http2` to `listen`) e.g. https://www.linode.com/docs/guides/how-to-configure-http-2-on-nginx/

# Roadmap
# Changelog

## Version 0.7 ##

- [View all images in a historic visualization][1]
- [Remove hard-coded paths][2]
- [Tests!][3]
- responsive full width display
- UI & wording updates
- show relative time since photo uploaded
- caching headers for static files
- auto-rotate iphone images
- system service for splitting the grid
- jinja loop fix
- pip/python2 bootstrap fix

## Version 0.6 ##

- Upgraded to Ubuntu 18.04 Bionic

## Version 0.5 ##

- Switched install from upstart to systemd for Ubuntu 16.04
- Moved to sockets for nginx to waznexserver communication

## Version 0.4 ##

[1]:https://github.com/brousch/WaznexServer/issues/3
[2]:https://github.com/brousch/WaznexServer/issues/7
[3]:https://github.com/brousch/WaznexServer/issues/11
- Added Vagrant for easier development
- Much improved Makefile for easier development and production installation
- Usable documentation

## Version 0.3 ##

- Newer versions of Flask and dependencies.
- Diagnostic image link between sizes and mark bad.
- Mark bad button.

## Version 0.2 ##

- It now has a database backend using SQLAlchemy instead of the thread-unsafe global list. This has only been tested with Sqlite so far.
- You can now control how many images are shown on the main page - it's no longer hard-coded to 3.

## Version 0.1 ##

- Version 0.1 includes the bare essentials of a working server.
- It can accept file uploads and will display the three most recent uploads using the mobile web theme.
- It generates two additional sized versions of each photo: a downsized version with maximum size of 1024x1024 pixels, and a thumbnail version with a maximum size of 316x316 pixels. The downsized version is useful for viewing on mobile platforms that limit download size (WebOS). The thumbnail version is sized to fit the mobile theme width.
79 changes: 0 additions & 79 deletions Vagrantfile

This file was deleted.

4 changes: 0 additions & 4 deletions waznexserver/misc/systemd/etc/nginx/sites-available/default
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ server {
alias /opt/waznexserver/WaznexServer/waznexserver/data/images/;
expires 10d;
}
location /diagnostic {
alias /opt/waznexserver/WaznexServer/waznexserver/data/diagnostic/;
expires 10d;
}
location /sliced {
alias /opt/waznexserver/WaznexServer/waznexserver/data/sliced/;
expires 10d;
Expand Down
Empty file modified waznexserver/process_grid.py
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion waznexserver/tests/hammeruploads/poster/streaminghttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
>>> s = "Test file data"
>>> f = StringIO(s)
>>> req = urllib2.Request("http://localhost:5000", f,
>>> req = urllib2.Request("http://localhost:8080", f,
... {'Content-Length': str(len(s))})
"""

Expand Down
Empty file modified waznexserver/utils.py
100644 → 100755
Empty file.
27 changes: 7 additions & 20 deletions waznexserver/waznexserver.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from sqlalchemy import or_
import timeago
from werkzeug import secure_filename
from werkzeug.security import safe_join

app = Flask(__name__)
app.config.from_object(__name__)
Expand Down Expand Up @@ -73,25 +74,11 @@ def show_image(filename):
app.logger.info('Serving image through Flask: ' + filename)
return send_from_directory(app.config['IMAGE_FOLDER'], filename)

@app.route('/diagnostic/<int:grid_item_id>')
def show_diagnostic(grid_item_id):
grid_item = db.session.query(models.GridItem).\
filter_by(id=grid_item_id).first()
gsp = grid_item.get_split_path()
filename = "lines.png"
app.logger.info('Serving diagnostic image through Flask: ' + filename)
return send_from_directory(os.path.join(app.config['SPLIT_FOLDER'], gsp),
filename)

@app.route('/sliced/<int:grid_item_id>/<filename>')
def show_sliced(grid_item_id, filename):
grid_item = db.session.query(models.GridItem).\
filter_by(id=grid_item_id).first()
gsp = grid_item.get_split_path()
app.logger.info('Serving cell through Flask: ' + gsp + '/' + filename)
return send_from_directory(os.path.join(app.config['SPLIT_FOLDER'], gsp),
filename)

@app.route('/sliced/<dirname>/<filename>')
def show_sliced(dirname, filename):
app.logger.info('Serving cell image through Flask: ' + filename)
return send_from_directory(app.config['SPLIT_FOLDER'], safe_join(dirname, filename))

@app.route('/colview/<int:grid_item_id>/<int:col_num>')
def show_colview(grid_item_id, col_num):
# Get column 0 - Room List
Expand Down Expand Up @@ -152,4 +139,4 @@ def mark_bad(grid_item_id):


if __name__ == '__main__':
app.run(host='0.0.0.0')
app.run(host='0.0.0.0', port=8080)

0 comments on commit 1e6a2ba

Please sign in to comment.