Skip to content

Commit

Permalink
Merge pull request #52 from zsk-poznan/ansible-docs
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
latachz authored Feb 17, 2020
2 parents b10771a + 5e861e3 commit 21fc332
Show file tree
Hide file tree
Showing 24 changed files with 41 additions and 238 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ on:
jobs:
buildx:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

- name: Login to Docker Hub
run: docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_TOKEN }}

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Run Buildx Backend
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/386,linux/arm/v7 \
--push \
./flask_app \
./backend \
-t zskpoznan/zastepstwa_backend
- name: Run Buildx Frontend
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ __pycache__
.pyc
.idea/
.vscode

ansible/roles

flask_app/Zastępstwa.html
backend/Zastępstwa.html
Zastępstwa.html

23 changes: 4 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ help: ## Display this help
@echo ''

start: ## Start all containers in background
@if ! [[ -d flask_app/venv ]]; then printf "\n\n\t It seems that you're running for the first time. This make take ~10-15 minutes so take a break. \n\n\n"; fi
@if ! [[ -d backend/venv ]]; then printf "\n\n\t It seems that you're running for the first time. This make take ~10-15 minutes so take a break. \n\n\n"; fi
docker-compose up --detach

stop: ## Stop all containers
Expand All @@ -25,25 +25,10 @@ logs: ## Display logs from all containers

# PRODUCTION

start-prod: ## Start in production mode
production: ## Run the latest version in production mode
docker-compose -f production.yml down
docker-compose -f production.yml pull
docker-compose -f production.yml up -d

stop-prod: ## Stop containers in production mode
docker-compose -f production.yml stop

logs-prod: ## Display logs from containers in production mode
docker-compose -f production.yml logs --tail 50 --follow

remove-prod: ## Remove containers in production mode
docker-compose -f production.yml down

# System setup

install: ## Install docker and docker-compose
set -eu pipefail
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y python3 python3-pip curl
curl -sSL https://get.docker.com | sh
pip3 install docker-compose
sudo usermod -aG docker $(USER)
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# zastepstwa-gui
# zastepstwa

## Install dependencies

```sh
pip3 install -r requirements.txt
```
Web app for displaying substitute teachers. This app runs in teacher room in our
school on Raspberry Pi with a touchscreen attached.

## Development

Expand All @@ -20,24 +17,33 @@ For more snippets type `make help`

## Deploy

``` sh
docker-compose -f production.yml up -d
To deploy you need to have
[ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
installed and ssh connection to the raspberry pi with raspbian installed. We
initially were using [ngrok](https://ngrok.com) to have connection. You use [this
service](ansible/ngrok-ssh.service) for this.

# or
make start-prod
```
If there's a reason that you don't want forward ssh you could try [this](#no_ssh)

### SSH

### Raspberry Pi configuration
Edit `ansible/hosts` to match your ssh configuration.

> All files for rpi configuration you can find in `/raspbian`
``` sh
ansible-galaxy install haxorof.docker_ce

We use RealVNC to connect to the rpi and also ngrok to have a ssh connection (`ngrok_ssh`).
ansible-playbook ansible/deploy.yml
```

On boot raspbian autologin to the `guest` user (`lightdm.conf`)
> This process could take a while since it checks if every dependency is
> installed. But thanks to that it's fully automatic so you don't need to do
> anything (unless an error occurs 😜)
@latachz created a script for starting chromium and configuring screen saver. (`kiosk.sh`)
### no_ssh

In home `/home/guest/.config/autostart` we start this script on system start.
If you don't want to share ssh, there is a way to run ansible locally.

Docker containers thanks to `restart: always` will automatically start.
* https://www.middlewareinventory.com/blog/run-ansible-playbook-locally/
* https://superuser.com/questions/336226/how-to-ssh-to-localhost-without-password

But it's easier if you have remote access.
2 changes: 1 addition & 1 deletion ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
update: yes

- name: Update containers
shell: docker-compose -f production.yml down; docker-compose -f production.yml pull && docker-compose -f production.yml up -d
shell: make production
args:
chdir: /home/pi/Desktop/zastepstwa-gui
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ services:
- ./frontend:/app
backend:
build:
context: flask_app
context: backend
dockerfile: Dockerfile.dev
ports:
- 5000:5000
volumes:
- ./flask_app:/app
- ./backend:/app
169 changes: 0 additions & 169 deletions raspbian/etc_lightdm_lightdm.conf

This file was deleted.

6 changes: 0 additions & 6 deletions raspbian/home_config_autostart_chromium.desktop

This file was deleted.

11 changes: 0 additions & 11 deletions raspbian/home_kiosk.sh

This file was deleted.

5 changes: 0 additions & 5 deletions start.sh

This file was deleted.

0 comments on commit 21fc332

Please sign in to comment.