Skip to content

Commit

Permalink
Normalize the dockerfiles and entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Robinson committed Sep 7, 2018
1 parent 8f3398b commit b454e59
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 30 deletions.
16 changes: 7 additions & 9 deletions cmd/satellite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ FROM brimstone/golang as build-env

# final stage
FROM alpine
ENV REDIS_ADDR=redis:6379 \
REDIS_PASSWORD= \
REDIS_DB=0 \
ENV CONF_PATH=/root/.storj/satellite/config.yaml \
OVERLAY_URL=redis://:redis@6379/?db=0 \
IDENTITY_ADDR=:7777 \
HTTP_PORT=:8080 \
BOOTSTRAP_ADDR=bootstrap.storj.io:8080
BOOTSTRAP_ADDR=bootstrap.storj.io:8080 \
MOCK_OVERLAY_NODES=
EXPOSE 7776/udp \
7777 \
8080
WORKDIR /app
COPY --from=build-env /app /app/satellite
COPY cmd/satellite/entrypoint /entrypoint
EXPOSE 8081/udp \
8080 \
7070

ENTRYPOINT ["/entrypoint"]
14 changes: 9 additions & 5 deletions cmd/satellite/entrypoint
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/sh
set -euo pipefail

RUN_PARAMS="${RUN_PARAMS:-} --overlay.database-url redis://:${REDIS_PASSWORD}@${REDIS_ADDR}/?db=${REDIS_DB} --debug.addr=${HTTP_PORT} --identity.address=${IDENTITY_ADDR}"
if [[ ! -f "${CONF_PATH}" ]]; then
./satellite setup
fi

RUN_PARAMS="${RUN_PARAMS:-} --config \"${CONF_PATH}\""

if [[ -f "${CONF_PATH:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --config \"${CONF_PATH}\""
else
./satellite setup
if [[ -n "${OVERLAY_URL:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --overlay.database-url ${OVERLAY_URL}"
fi

RUN_PARAMS="${RUN_PARAMS} --identity.address=${IDENTITY_ADDR}"

if [[ -n "${API_KEY}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --pointer-db.auth.api-key ${API_KEY}"
fi
Expand Down
6 changes: 3 additions & 3 deletions cmd/storagenode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ FROM brimstone/golang as build-env

# final stage
FROM alpine
ENV CONF_PATH= \
ENV CONF_PATH=/root/.storj/storagenode/config.yaml \
SATELLITE_ADDR=
EXPOSE 7777

EXPOSE 7776/udp \
7777
WORKDIR /app
COPY --from=build-env /app /app/storagenode
COPY cmd/storagenode/entrypoint /entrypoint
Expand Down
12 changes: 4 additions & 8 deletions cmd/storagenode/entrypoint
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/bin/sh
set -euo pipefail

RUN_PARAMS="${RUN_PARAMS:-}"

if [[ -f "${CONF_PATH:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --config \"${CONF_PATH}\""
else
if [[ ! -d $HOME/.storj/storagenode ]]; then
./storagenode setup
fi
if [[ ! -f "${CONF_PATH}" ]]; then
./storagenode setup
fi

RUN_PARAMS="${RUN_PARAMS:-} --config \"${CONF_PATH}\""

if [ -n "${SATELLITE_ADDR:-}" ]; then
RUN_PARAMS="${RUN_PARAMS} --kademlia.bootstrap-addr $SATELLITE_ADDR"
fi
Expand Down
8 changes: 4 additions & 4 deletions cmd/uplink/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ FROM brimstone/golang as build-env

# final stage
FROM alpine
ENV API_KEY= \
ENV CONF_PATH=/root/.storj/uplink/config.yaml \
API_KEY= \
SATELLITE_ADDR=
EXPOSE 7777


EXPOSE 7776/udp \
7777
WORKDIR /app
COPY --from=build-env /app /app/uplink
COPY cmd/uplink/entrypoint /entrypoint
Expand Down
15 changes: 14 additions & 1 deletion cmd/uplink/entrypoint
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/bin/sh
set -euo pipefail

./uplink setup --api-key "${API_KEY}" --satellite-addr "${SATELLITE_ADDR}"
if [[ ! -f "${CONF_PATH}" ]]; then
./uplink setup
fi

RUN_PARAMS="${RUN_PARAMS:-} --config \"${CONF_PATH}\""

if [[ -n "${API_KEY}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --api-key ${API_KEY}"
fi

if [ -n "${SATELLITE_ADDR:-}" ]; then
RUN_PARAMS="${RUN_PARAMS} --overlay-addr $SATELLITE_ADDR"
RUN_PARAMS="${RUN_PARAMS} --pointer-db-addr $SATELLITE_ADDR"
fi

exec ./uplink run "$@"

0 comments on commit b454e59

Please sign in to comment.