Normalize the Docker Bits (#325)

* Normalize the dockerfiles and entrypoints

* fix formattting and docker-compose file

* add missing env var to satellite dockerfile

* Remove build args no longer in use

* More changes to make it all work
This commit is contained in:
Matt Robinson 2018-09-07 15:46:08 -04:00 committed by Philip Hutchins
parent 8f3398b349
commit 75c64035a2
9 changed files with 53 additions and 39 deletions

View File

@ -19,9 +19,7 @@ FILEEXT := .exe
endif endif
DOCKER_BUILD := docker build \ DOCKER_BUILD := docker build \
--build-arg GO_VERSION=${GO_VERSION} \ --build-arg GO_VERSION=${GO_VERSION}
--build-arg GOOS=${GOOS} \
--build-arg GOARCH=${GOARCH}
# currently disabled linters: # currently disabled linters:
# gofmt # enable after switch to go1.11 # gofmt # enable after switch to go1.11

View File

@ -5,17 +5,16 @@ FROM brimstone/golang as build-env
# final stage # final stage
FROM alpine FROM alpine
ENV REDIS_ADDR=redis:6379 \ ENV API_KEY= \
REDIS_PASSWORD= \ CONF_PATH=/root/.storj/satellite/config.yaml \
REDIS_DB=0 \ OVERLAY_URL=redis://redis:6379/?db=0 \
IDENTITY_ADDR=:7777 \ 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 WORKDIR /app
COPY --from=build-env /app /app/satellite COPY --from=build-env /app /app/satellite
COPY cmd/satellite/entrypoint /entrypoint COPY cmd/satellite/entrypoint /entrypoint
EXPOSE 8081/udp \
8080 \
7070
ENTRYPOINT ["/entrypoint"] ENTRYPOINT ["/entrypoint"]

View File

@ -1,14 +1,18 @@
#!/bin/sh #!/bin/sh
set -euo pipefail 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
if [[ -f "${CONF_PATH:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --config \"${CONF_PATH}\""
else
./satellite setup
fi fi
RUN_PARAMS="${RUN_PARAMS:-} --config ${CONF_PATH}"
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 if [[ -n "${API_KEY}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --pointer-db.auth.api-key ${API_KEY}" RUN_PARAMS="${RUN_PARAMS} --pointer-db.auth.api-key ${API_KEY}"
fi fi
@ -17,4 +21,8 @@ if [[ -n "${BOOTSTRAP_ADDR:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --kademlia.bootstrap-addr ${BOOTSTRAP_ADDR}" RUN_PARAMS="${RUN_PARAMS} --kademlia.bootstrap-addr ${BOOTSTRAP_ADDR}"
fi fi
if [[ -n "${MOCK_OVERLAY_NODES:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --mock-overlay.nodes ${MOCK_OVERLAY_NODES}"
fi
exec ./satellite run $RUN_PARAMS "$@" exec ./satellite run $RUN_PARAMS "$@"

View File

@ -5,10 +5,10 @@ FROM brimstone/golang as build-env
# final stage # final stage
FROM alpine FROM alpine
ENV CONF_PATH= \ ENV CONF_PATH=/root/.storj/storagenode/config.yaml \
SATELLITE_ADDR= SATELLITE_ADDR=
EXPOSE 7777 EXPOSE 7776/udp \
7777
WORKDIR /app WORKDIR /app
COPY --from=build-env /app /app/storagenode COPY --from=build-env /app /app/storagenode
COPY cmd/storagenode/entrypoint /entrypoint COPY cmd/storagenode/entrypoint /entrypoint

View File

@ -1,16 +1,12 @@
#!/bin/sh #!/bin/sh
set -euo pipefail set -euo pipefail
RUN_PARAMS="${RUN_PARAMS:-}" if [[ ! -f "${CONF_PATH}" ]]; then
./storagenode setup
if [[ -f "${CONF_PATH:-}" ]]; then
RUN_PARAMS="${RUN_PARAMS} --config \"${CONF_PATH}\""
else
if [[ ! -d $HOME/.storj/storagenode ]]; then
./storagenode setup
fi
fi fi
RUN_PARAMS="${RUN_PARAMS:-} --config ${CONF_PATH}"
if [ -n "${SATELLITE_ADDR:-}" ]; then if [ -n "${SATELLITE_ADDR:-}" ]; then
RUN_PARAMS="${RUN_PARAMS} --kademlia.bootstrap-addr $SATELLITE_ADDR" RUN_PARAMS="${RUN_PARAMS} --kademlia.bootstrap-addr $SATELLITE_ADDR"
fi fi

View File

@ -5,11 +5,11 @@ FROM brimstone/golang as build-env
# final stage # final stage
FROM alpine FROM alpine
ENV API_KEY= \ ENV CONF_PATH=/root/.storj/uplink/config.yaml \
API_KEY= \
SATELLITE_ADDR= SATELLITE_ADDR=
EXPOSE 7777 EXPOSE 7776/udp \
7777
WORKDIR /app WORKDIR /app
COPY --from=build-env /app /app/uplink COPY --from=build-env /app /app/uplink
COPY cmd/uplink/entrypoint /entrypoint COPY cmd/uplink/entrypoint /entrypoint

View File

@ -1,6 +1,19 @@
#!/bin/sh #!/bin/sh
set -euo pipefail set -euo pipefail
./uplink setup --api-key "${API_KEY}" --satellite-addr "${SATELLITE_ADDR}" if [[ ! -f "${CONF_PATH}" ]]; then
./uplink setup
fi
exec ./uplink run "$@" 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 $RUN_PARAMS "$@"

View File

@ -16,11 +16,11 @@ services:
- satellite - satellite
satellite: satellite:
image: storjlabs/satellite:${VERSION} image: storjlabs/satellite:${VERSION}
command: --mock-overlay.nodes INTENTIONALLY:LEFT:BLANK
environment: environment:
- API_KEY=abc123 - API_KEY=abc123
- IDENTITY_ADDR=:7777
- BOOTSTRAP_ADDR=localhost:8080 - BOOTSTRAP_ADDR=localhost:8080
- IDENTITY_ADDR=:7777
- MOCK_OVERLAY_NODES=INTENTIONALLY:LEFT:BLANK
links: links:
- redis - redis
depends_on: depends_on:
@ -31,7 +31,7 @@ services:
image: storjlabs/uplink:${VERSION} image: storjlabs/uplink:${VERSION}
command: --min-threshold 1 --max-threshold 1 --repair-threshold 1 --success-threshold 1 command: --min-threshold 1 --max-threshold 1 --repair-threshold 1 --success-threshold 1
environment: environment:
- SATELLITE_ADDR=satellite:7777
- API_KEY=abc123 - API_KEY=abc123
- SATELLITE_ADDR=satellite:7777
ports: ports:
- 7777:7777 - 7777:7777

View File

@ -9,4 +9,4 @@ for cid in $(docker ps -a | awk '/storagenode/{print $1}'); do
echo $id:$ip:7777 echo $id:$ip:7777
done | tr '\n' ',' done | tr '\n' ','
)" )"
sed -i'' -e "s/nodes .*$/nodes ${ids%,}/" docker-compose.yaml sed -i'' -e "s/NODES=.*$/NODES=${ids%,}/" docker-compose.yaml