Skip to content

Swift backend (nh-lighting) for the hackspace automated lighting

License

Notifications You must be signed in to change notification settings

NottingHack/instrumentation-lighting

Repository files navigation

nh-lighting

macOS Linux MIT

Server side swift for the hackspace automated lighting

macOS

Code can be build with either the Xcode project or with swift build

Docker deployment

Currently this is running on Queen

The PADockerfiles are generated by Perfect Assistant 3.0

Prep work

Adding the instrumentation network to docker (only needs to be done once)

sudo docker network create -d macvlan  \
    --subnet=192.168.0.0/24  \
    --ip-range=192.168.0.128/25 \
    --gateway=192.168.0.1  \
    -o parent=eth0.3 instrumentation

Build the intermediary docker image with our dependencies, only needs doing if PADockerfile_build has changed

sudo docker build -f PADockerfile_build -t perfectassistant/nh-lighting .

Compiling

Use our image to compile

sudo docker run \
    --volume=/home/dpslwk/github/instrumentation-lighting:/perfectbuild \
    --volume=/home/dpslwk/github/instrumentation-lighting/.packages_lin:/perfectbuild/Packages \
    --volume=/home/dpslwk/github/instrumentation-lighting/.build_lin:/perfectbuild/.build \
    --volume=/home/dpslwk/github/instrumentation-lighting/.package_lin.pins:/perfectbuild/Package.pins \
    --volume=/home/dpslwk/github/instrumentation-lighting/.package_lin.resolved:/perfectbuild/Package.resolved \
    --workdir=/perfectbuild --rm -t perfectassistant/nh-lighting swift build

Running in place

Running with files from current location, usefully for testing and change iteration

Create a container

sudo docker create \
    --volume=/home/dpslwk/github/instrumentation-lighting:/perfectbuild \
    --volume=/home/dpslwk/github/instrumentation-lighting/.packages_lin:/perfectbuild/Packages \
    --volume=/home/dpslwk/github/instrumentation-lighting/.build_lin:/perfectbuild/.build \
    --volume=/home/dpslwk/github/instrumentation-lighting/.package_lin.pins:/perfectbuild/Package.pins \
    --volume=/home/dpslwk/github/instrumentation-lighting/.package_lin.resolved:/perfectbuild/Package.resolved \
    --workdir=/perfectbuild --rm -t -p 8181:8181 --name nh-lighting perfectassistant/nh-lighting .build_lin/debug/nh-lighting

Connect our container to the instrumentation network

sudo docker network connect instrumentation nh-lighting

and start the container

sudo docker start nh-lighting

Running with deployment image

For long term deployment its better to build an images with all the files included

Compile for release

sudo docker run \
    --volume=/home/dpslwk/github/instrumentation-lighting:/perfectbuild \
    --volume=/home/dpslwk/github/instrumentation-lighting/.packages_lin:/perfectbuild/Packages \
    --volume=/home/dpslwk/github/instrumentation-lighting/.build_lin:/perfectbuild/.build \
    --volume=/home/dpslwk/github/instrumentation-lighting/.package_lin.pins:/perfectbuild/Package.pins \
    --volume=/home/dpslwk/github/instrumentation-lighting/.package_lin.resolved:/perfectbuild/Package.resolved \
    --workdir=/perfectbuild --rm -t perfectassistant/nh-lighting swift build -c release

Build a deploy image

sudo docker build -f PADockerfile_deploy -t perfectassistant/nh-lighting:deploy .

Create a container using this image, connect to the instrumentation network and start the container

sudo docker create \
    --restart=unless-stopped -t -p 8181:8181 --name nh-lighting perfectassistant/nh-lighting:deploy 
sudo docker network connect instrumentation nh-lighting
sudo docker start nh-lighting

Running with docker-compose (for dev only)

If you have docker-compose installed you can save yourself some typing

Compile with dockerised build environment

docker-compose -f build.yml up --build

Run in place

docker-compose up --build --detach

See build.yml and docker-compose.yml for further information

DB reload

A SIGHUB will cause force a db reload

macOS

pkill -1 nh-lighting

Docker

sudo docker kill --signal=HUP nh-lighting

docker-compose

docker-compose kill -s HUP nh-lighting

About

Swift backend (nh-lighting) for the hackspace automated lighting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published