Skip to content

Commit

Permalink
move and create dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVerstraete committed Jan 22, 2021
1 parent eb67aa1 commit f806ce8
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 42 deletions.
4 changes: 2 additions & 2 deletions graphql/.env → .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ REDIS_URI=redis://localhost:6379/0
###########################

# Where the mapping scripts are located, relative to ./generated/indexer
MAPPINGS_LOCATION=../../mappings
# TYPES_JSON=../../client/types.json
MAPPINGS_LOCATION=./graphql/mappings
# TYPES_JSON=./api-client/types.json

# Indexer GraphQL API endpoint to fetch indexed events
INDEXER_ENDPOINT_URL=http://localhost:4000/graphql
Expand Down
6 changes: 3 additions & 3 deletions graphql/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
image: hydra-kit:latest
restart: unless-stopped
build:
dockerfile: docker/Dockerfile.hydra
dockerfile: ./graphql/docker/Dockerfile.hydra
context: ./
env_file:
- .env
Expand All @@ -43,7 +43,7 @@ services:
- TYPES_JSON=/types.json
volumes:
- type: bind
source: /home/dylan/Projects/substrate-tfgrid/client/types.json
source: ./api-client/types.json
target: /home/hydra-indexer/types.json
depends_on:
- db
Expand All @@ -54,7 +54,7 @@ services:
image: hydra-kit:latest
restart: unless-stopped
build:
dockerfile: docker/Dockerfile.hydra
dockerfile: ./graphql/docker/Dockerfile.hydra
context: ./
env_file:
- .env
Expand Down
70 changes: 35 additions & 35 deletions substrate-node/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions substrate-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Note: We don't use Alpine and its packaged Rust/Cargo because they're too often out of date,
# preventing them from being used to build Substrate/Polkadot.

FROM phusion/baseimage:0.11 as builder
LABEL maintainer="[email protected]"
LABEL description="This is the build stage for Substrate. Here we create the binary."

ENV DEBIAN_FRONTEND=noninteractive

ARG PROFILE=release
WORKDIR /substrate

COPY . /substrate

RUN apt-get update && \
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \
apt-get install -y cmake pkg-config libssl-dev git clang

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
export PATH="$PATH:$HOME/.cargo/bin" && \
rustup install nightly-2020-10-01 && \
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-01 && \
rustup default stable && \
cargo +nightly-2020-10-01 build "--$PROFILE"

# ===== SECOND STAGE ======

FROM phusion/baseimage:0.11
LABEL maintainer="[email protected]"
LABEL description="This is the 2nd stage: a very small image where we copy the Substrate binary."
ARG PROFILE=release

RUN mv /usr/share/ca* /tmp && \
rm -rf /usr/share/* && \
mv /tmp/ca-certificates /usr/share/ && \
useradd -m -u 1000 -U -s /bin/sh -d /substrate substrate && \
mkdir -p /substrate/.local/share/substrate && \
chown -R substrate:substrate /substrate/.local && \
ln -s /substrate/.local/share/substrate /data

COPY --from=builder /substrate/target/$PROFILE/substrate /usr/local/bin

# checks
RUN ldd /usr/local/bin/substrate && \
/usr/local/bin/substrate --version

# Shrinking
RUN rm -rf /usr/lib/python* && \
rm -rf /usr/bin /usr/sbin /usr/share/man

USER substrate
EXPOSE 30333 9933 9944 9615
VOLUME ["/data"]

CMD ["/usr/local/bin/substrate --ws-external"]
32 changes: 32 additions & 0 deletions substrate-node/docker/Dockerfile.back
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM debian:stretch-slim
# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libssl1.1 \
ca-certificates \
glibc \
curl && \

# apt cleanup
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
# add user
useradd -m -u 1000 -U -s /bin/sh -d /node-template substrate

# add substrate binary to docker image
COPY ./node-template /usr/local/bin

USER substrate

# check if executable works in this container
RUN /usr/local/bin/node-template --version

EXPOSE 30333 9933 9944
VOLUME ["./node-template"]

ENTRYPOINT ["/usr/local/bin/node-template --ws-external"]
4 changes: 2 additions & 2 deletions substrate-node/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ description = 'A fresh FRAME-based Substrate node, ready for hacking.'
edition = '2018'
homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template'
name = 'substrate'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '2.0.0'

[[bin]]
name = 'node-template'
name = 'substrate'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
Expand Down
30 changes: 30 additions & 0 deletions substrate-node/scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM debian:stretch-slim
# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libssl1.1 \
ca-certificates \
curl && \
# apt cleanup
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
# add user
useradd -m -u 1000 -U -s /bin/sh -d /node-template substrate

# add substrate binary to docker image
COPY ../target/release/node-template /usr/local/bin

USER substrate

# check if executable works in this container
RUN /usr/local/bin/node-template --version

EXPOSE 30333 9933 9944
VOLUME ["../target/release/node-template"]

ENTRYPOINT ["/usr/local/bin/node-template --ws-external"]

0 comments on commit f806ce8

Please sign in to comment.