diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..f860d2cfd9c81325361dac8a69fdbe278da3d739 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +# Database directory +mainnetdb/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6e89c3877298ef67819487b7b9082f04ad83af4f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# we need to use alpine to build since cgo is required +FROM golang:1.12-alpine AS build +RUN apk add --no-cache git gcc g++ + +# Set the current Working Directory inside the container +RUN mkdir /goshimmer +WORKDIR /goshimmer + +# Download dependencies +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Copy everything from the current directory to the PWD(Present Working Directory) inside the container +COPY . . + +# Build +RUN CGO_ENABLED=1 GOOS=linux go build -o /go/bin/goshimmer + +FROM alpine:latest + +RUN apk --no-cache add ca-certificates + +WORKDIR /root/ + +VOLUME /root/mainnetdb + +EXPOSE 14666/tcp +EXPOSE 14626/udp +EXPOSE 14626/tcp + +# Copy the Pre-built binary file from the previous stage +COPY --from=build /go/bin/goshimmer . + +ENTRYPOINT ["./goshimmer"] diff --git a/README.md b/README.md index 3716652d10694744bfce05d3ff189bc9dc0ea5d8..230791e27fa775f529e48b219d51e73171133b87 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,21 @@ You can then run by: ``` ./shimmer -``` \ No newline at end of file +``` + +## Docker + +To run Shimmer on docker, you must first build the image with +``` +docker build -t iotaledger/goshimmer . +``` +and then run it with +``` +docker run --rm -it -v target/mainnetdb:/root/mainnetdb iotaledger/goshimmer +``` +You may replace `target/mainnetdb` with a custom path to the database folder. + +To start Shimmer in the background, you can also simply use [Docker Compose](https://docs.docker.com/compose/) by running +``` +docker-compose up -d +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..b5687209da3b41f945d25e48c84ca616aa42e8ff --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" + +services: + + goshimmer: + image: iotaledger/goshimmer + container_name: iota_goshimmer + restart: unless-stopped + volumes: + - ./mainnetdb:/root/mainnetdb:rw + ports: + - "14666:14666/tcp" + - "14626:14626/udp" + - "14626:14262/tcp" + command: "-node-disable-plugins statusscreen"