Giter Club home page Giter Club logo

vaporberrypi's Introduction

Introduction

This is a demo for getting Vapor running on a Raspberry Pi using swift 4.1.1 from the swift-arm port.

Getting Started

Develop on desktop, run on RaspberryPi

Steps to do on your Raspberry Pi

  1. Setup your Raspberry Pi with Raspbian Stretch
  2. Enable ssh
  3. Install swift 4.1.1 from the swift-arm port
  4. Clone a bare git repo, e.g. sudo mkdir /git && sudo git clone --bare ssh://[email protected]/git/VaporberryPi.git /git/VaporberryPi.git && sudo chown -R pi:pi /git
  5. Add a post-receive hook script to your bare git repo that runs when you push new code to it (see post-receive hook example in Appendix)
  6. Clone your bare git repo to create a working git repo, e.g. git clone ssh://pi@localhost/git/VaporberryPi.git ~/VaporberryPi

Steps to do on your desktop computer

  1. Clone VaporberryPi from the bare repo on your Raspberry Pi, e.g. git clone ssh://[email protected]/git/VaporberryPi.git
  2. Change current directory to your VaporberryPi clone, e.g. cd VaporberryPi
  3. Use ssh to connect to your Raspberry Pi to confirm the connection, e.g. ssh [email protected] -- hostname
  4. Push to your bare repo: git push origin
    • Confirm in the git push origin output that the project builds and runs successfully on the Raspberry Pi
  5. Open a web browser and go to http://raspberrypi.local:8080
    • Confirm output: "It works!"

Next Steps

John Woolsey trailblazed this topic with Controlling A Raspberry Pi From A Web Browser With Vapor 3. Check it out for a tutorial on next steps, like how to integrate an LED into the program.

Appendix

post-receive hook example

This post-receive hook:

  1. changes the active directory to the working git repo,
  2. fetches new changes from the bare repo and resets its state to match,
  3. executes the Procfile script and logs its output to a file in /tmp.
$ chmod +x /git/VaporberryPi.git/hooks/post-receive

$ ls -ld /git/VaporberryPi.git/hooks/post-receive
-rwxr-xr-x 1 pi pi 254 Mar 10 14:11 /git/VaporberryPi.git/hooks/post-receive

$ cat /git/VaporberryPi.git/hooks/post-receive
#!/bin/bash -e
code_dir=~/VaporberryPi
cd "$code_dir"
git --git-dir "$code_dir/.git" --work-tree "$code_dir" fetch --all origin master
git --git-dir "$code_dir/.git" --work-tree "$code_dir" reset --hard origin/master
git --git-dir "$code_dir/.git" --work-tree "$code_dir" clean --force
log=/tmp/"$(basename "$code_dir")"-post-receive.log
./Procfile | tee "$log"
exit

Vapor

API Template

Documentation Team Chat MIT License Continuous Integration Swift 4.1

vaporberrypi's People

Contributors

bjo0 avatar

Stargazers

Mikhail Isaev aka iMike avatar Drygan_dev avatar  avatar Zeeshan Aamir avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.