Skip to content

Instantly share code, notes, and snippets.

@fernandoabolafio
Last active April 29, 2019 14:31
Show Gist options
  • Save fernandoabolafio/19c3fdb8751913094d3f5189b4ea3df9 to your computer and use it in GitHub Desktop.
Save fernandoabolafio/19c3fdb8751913094d3f5189b4ea3df9 to your computer and use it in GitHub Desktop.
Politeia Dockerfile

Politeia Dockerfile

This gist contains the Dockerfile used to generate the docker image for Politeia.

This docker setup is intended only for development purposes. Do not rely on it for production setup.

Running politeia from the remote image

  • Get the image: docker pull fabolafio/politeia

  • Run the container: docker run -d -p 4443:4443 politeia

Now you should have politeiawww running on port 4443 of your localhost.

Building your own image

  • Install docker
  • Copy the Dockerfile into the root of Politeia
  • run docker build -t my-politeia-image .

Runnint CMS mode

Politeiawww has a CMS mode used for managing contractors invoivces and payments. To run politeia on this mode, execute: docker run -d -p 4443:4443 -e MODE=cmswww politeia

FROM ubuntu:latest
LABEL description="politeia quick setup"
LABEL version="1.0"
LABEL maintainer "oxfernando@gmail.com"
RUN apt-get update
RUN apt-get install -y wget git gcc
# Install Go
RUN wget -P /tmp https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf /tmp/go1.11.5.linux-amd64.tar.gz
RUN rm /tmp/go1.11.5.linux-amd64.tar.gz
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
# Create shortcut to start cockroachdb
ENV cdbstart="cockroach start --background --certs-dir=/root/.cockroachdb/certs/node --listen-addr=localhost --store=/root/.cockroachdb/data"
# Create variables for default configs
ENV MODE "piwww"
RUN mkdir /politeia
WORKDIR /politeia
# Install cockroachdb
RUN wget -qO- https://binaries.cockroachdb.com/cockroach-v2.1.6.linux-amd64.tgz | tar xvz
RUN cp -i cockroach-v2.1.6.linux-amd64/cockroach /usr/local/bin
# Copy directory files
COPY . .
# Install politeia packages
RUN go install ./...
RUN ./cockroachcerts.sh /root/.cockroachdb
RUN nohup bash -c \
"$cdbstart" \
&& sleep 4 && ./cachesetup.sh /root/.cockroachdb && ./cmssetup.sh /root/.cockroachdb
# Add politead configuration file
RUN mkdir /root/.politeiad
RUN mkdir /root/.politeiawww
RUN echo "\
rpcuser=user \n\
rpcpass=pass \n\
testnet=true \n\
enablecache=true \n\
cachehost=localhost:26257 \n\
cacherootcert=/root/.cockroachdb/certs/clients/politeiad/ca.crt \n\
cachecert=/root/.cockroachdb/certs/clients/politeiad/client.politeiad.crt \n\
cachekey=/root/.cockroachdb/certs/clients/politeiad/client.politeiad.key" > /root/.politeiad/politeiad.conf
# Add politeawww configuration file
RUN echo "\
mode=$MODE \n\
rpchost=127.0.0.1 \n\
rpcuser=user \n\
rpcpass=pass \n\
rpccert=~/.politeiad/https.cert \n\
testnet=true \n\
paywallxpub=tpubVobLtToNtTq6TZNw4raWQok35PRPZou53vegZqNubtBTJMMFmuMpWybFCfweJ52N8uZJPZZdHE5SRnBBuuRPfC5jdNstfKjiAs8JtbYG9jx \n\
paywallamount=10000000 \n\
dbhost=localhost:26257 \n\
dbrootcert=/root/.cockroachdb/certs/clients/politeiawww/ca.crt \n\
dbcert=/root/.cockroachdb/certs/clients/politeiawww/client.politeiawww.crt \n\
dbkey=/root/.cockroachdb/certs/clients/politeiawww/client.politeiawww.key" > /root/.politeiawww/politeiawww.conf
# Fetch identity from politeiad
RUN nohup bash -c "$cdbstart" && nohup bash -c "politeiad &" && sleep 4 && politeiawww --fetchidentity
# Expose politeiawww port
EXPOSE 4443
CMD nohup bash -c "$cdbstart" && nohup bash -c "politeiad &" && sleep 4 && politeiawww --mode="$MODE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment