Skip to content

Docker

Running in Docker

The simplest way is to first build plaid, copy the executable and plugin file into a separate folder then build and run the image.

The following files are required to run plaid:

  • plaidven executable (built)
  • plaidven plugin file
  • Config and schema files
  • Any security certificates

Make sure to expose the port when running the container (e.g. with the flag -p 8282:8282) if you'd like to be able to send requests to the API. In order for the Plaid plugin to connect to a server running on your localhost you'll need to input the docker specific endpoint in the plugin url instead of localhost, as explained in this stackoverflow: https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach

The Dockerfile will build from an image, install the necessary dependencies, copy the required files and then run the executable.

The following files will build the config and all other assets into the image. An alternative approach is to mount the working directory as you run the docker container, so you don't have to rebuild the docker image after updating the config file.

Ubuntu 16.04

Ubuntu 16.04 dockerfile (requires executable build in Ubuntu 16.04):

FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
  libcurl3 libcurl4-openssl-dev ca-certificates libxerces-c-dev

COPY . .

EXPOSE 8282

CMD ./plaidven schema.json config.json

Ubuntu 18.04

Ubuntu 18.04 dockerfile (requires executable built in Ubuntu 18.04):

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y --no-install-recommends \
  openssl libxerces-c-dev libssl-dev libcurl4-openssl-dev ca-certificates

COPY . .

EXPOSE 8282

CMD ./plaidven schema.json config.json

Building in Docker

Use the following dockerfile to create an ubuntu:18.04 docker container that will allow you to build a Plaid Binary and then run it. Rather than copy the source code into the docker image, this method mounts your local files. The build binary will be available in your file system for future use (e.g. if you would like to run it more simply in the future), and you can make changes to the config files without updating the docker image.

# docker build -t plaid-build --build-arg USER_UID=`id -u` --build-arg USER_GID=`id -g` --build-arg USER_NAME=`id -un`  - < Dockerfile
# docker run -it --rm -v $PWD:/src/ -u `id -u` plaid-build /bin/bash

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y --no-install-recommends cmake build-essential libxerces-c-dev curl openssl libcurl4-openssl-dev libssl-dev ca-certificates
RUN rm -rf /var/lib/apt/lists/*

VOLUME /src
WORKDIR /src

#The next 5 lines may not be necessary - delete if causing an error

ARG USER_NAME
ARG USER_UID
ARG USER_GID
RUN groupadd --gid $USER_GID $USER_NAME
RUN useradd -m --uid $USER_UID --gid $USER_GID $USER_NAME
  1. Copy the Dockerfile to the root directory and name the file Dockerfile
  2. Run the first command in the dockerfile to create the image. This will create an Ubuntu 18.04 image with all the necessary dependencies to build and run Plaid
  3. Run the container - the second command will run a container and place you in the command line in the container
  4. From there, build and run Plaid by following the linux build instructions
  5. The container will be destroyed when you exit out of it, but the binary will stay in your file system