Skip to content

Developing with Docker

AdrianP edited this page Oct 6, 2020 · 4 revisions

Developing with Docker

Home


Freeboard makes it easy to work with a Signal K server hosted either on your development device or another device.

You can specify the Ip address of the Signal K server to use during development by setting the value of the DEV_SERVER object in the file src/app/app.info.ts.

export class AppInfo extends Info {

    private DEV_SERVER= {
        host: '172.17.0.1', //'192.168.86.32', //'172.17.0.1', // host name || ip address
        port: 3000,     // port number
        ssl: false
    };
   ...
}

Hosting Signal K server in Docker:

An example Dockerfile for composing a Signal K server image to use for development purposes.

ARG IMAGE_BASE=node
FROM $IMAGE_BASE:10

COPY empty_file tmp/qemu-arm-stati[c] /usr/bin/

RUN apt-get update && apt-get -y install libavahi-compat-libdnssd-dev

#*********** DEV ***********
RUN apt-get update && apt-get -y install sudo
RUN apt-get update && apt-get -y install curl

RUN usermod -aG sudo node
#***************************
USER node
RUN mkdir -p /home/node/signalk
WORKDIR /home/node/signalk

COPY --chown=node:node . .
RUN npm install
RUN npm run build
RUN mkdir -p /home/node/.signalk

# ** install some plugins **
RUN cd /home/node/.signalk && \
	npm i signalk-anchoralarm-plugin \
		signalk-derived-data \
		signalk-to-influxdb \
		signalk-buddylist-plugin

EXPOSE 3000
ENV IS_IN_DOCKER true
ENTRYPOINT /home/node/signalk/bin/signalk-server --securityenabled

Create the image using the following command: docker build -t skserver .

The you can then start the container with the following command with paths to your relevant development folders on your host device:

docker run --name skserver --rm -p 3000:3000 \
    -v ~mydevFolder/.signalk/plugin-config-data:/home/node/.signalk/plugin-config-data \
    -v ~mydevFolder/app:/usr/src/app \
    -v ~mydevFolder/res_files:/usr/resources \
    -v ~mydevFolder/plugins:/usr/plugins \
    -it --entrypoint /bin/bash skserver

Host both Freeboard development in Docker.

FROM node

RUN npm i -g @angular/cli@latest

RUN mkdir /app/
WORKDIR /app/

COPY package.json /app/
RUN npm i

COPY . /app/

CMD ["npm", "start"]

Using docker-compose to for Both Development and server

Using the follwoing file and running the command docker-compose up you can have all your docker containers started and ready to go.

Example: docker-compose.yml

version: '3.7'
services:
  signalk_server:
    image: signalk/signalk-server
    container_name: signalk_server
    # build:
    #   context: ../signalk-server
    ports:
      - 3000:3000
    init: true
    entrypoint: bin/signalk-server
    command: --sample-nmea0183-data
  freeboard_sk:
    build:
      context: .
    command: ng serve --host 0.0.0.0
    ports:
      - 4200:4200
    depends_on:
      - signalk_server
    volumes:
      - .:/app/
      - /app/node_modules