Skip to content

Commit

Permalink
Added stop feature for docker
Browse files Browse the repository at this point in the history
s

ss

ss

ss

ss
  • Loading branch information
alifiratari committed Jul 20, 2022
1 parent 1214f23 commit 68cb1fa
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.history/

4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN mkdir -p docker operator config \
&& cp fonoster/etc/service_envs.json config \
&& cp fonoster/etc/install.sh . \
&& cp fonoster/etc/update.sh . \
&& cp fonoster/etc/stop.sh . \
&& rm -rf fonoster

##
Expand All @@ -45,12 +46,13 @@ RUN mkdir -p docker operator config \
FROM stage AS serve
WORKDIR /work

COPY --from=stage /work/install.sh /work/update.sh ./
COPY --from=stage /work/install.sh /work/update.sh /work/stop.sh ./
COPY --from=stage /work/docker /work/docker

RUN find . -type f -iname "*.sh" -exec chmod +x {} + \
&& mv /work/install.sh /install.sh \
&& mv /work/update.sh /update.sh \
&& mv /work/stop.sh /stop.sh \
&& mv /work/docker /docker \
&& chown -R fonoster:fonoster /work

Expand Down
25 changes: 19 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/install.sh" \
fonoster/fonoster:0.3.6-alpha.5
fonoster/fonoster:0.3.12
```

#### Install (With extra services)
Expand All @@ -26,7 +26,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/install.sh" \
fonoster/fonoster:0.3.6-alpha.5
fonoster/fonoster:0.3.12
```

#### Install (Passing version)
Expand All @@ -41,7 +41,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/install.sh" \
fonoster/fonoster:0.3.6-alpha.5
fonoster/fonoster:0.3.12
```

#### Install (Verbose mode)
Expand All @@ -56,7 +56,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/install.sh" \
fonoster/fonoster:0.3.6-alpha.5
fonoster/fonoster:0.3.12
```

#### Update (Happy path)
Expand All @@ -69,7 +69,7 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/update.sh" \
fonoster/fonoster:0.3.6-alpha.5
fonoster/fonoster:0.3.12
```

#### Update (Passing version and verbose)
Expand All @@ -84,5 +84,18 @@ docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/update.sh" \
fonoster/fonoster:0.3.6-alpha.5
fonoster/fonoster:0.3.12
```

#### Stop (Happy path)

Stop your current installation.

```bash
docker run -it --rm \
-e CONFIG_PATH=$(pwd)/fonoster/config \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume $(pwd)/fonoster:/out:rw \
--entrypoint="/stop.sh" \
fonoster/fonoster:0.3.12
```
23 changes: 23 additions & 0 deletions docker/commands/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

function stop() {
local VERSION COMPOSE_PROJECT_VERSION

info "Stopping Fonoster application... 🚀 "

execute "cd /out/operator"

[ -f .env ] || error "You don't have a Fonoster application installed in this directory. Please, install it first."

VERSION=$FONOSTER_VERSION
COMPOSE_PROJECT_VERSION=$(grep COMPOSE_PROJECT_VERSION .env | cut -d '=' -f2)

EXTRA_SERVICES=$(grep EXTRA_SERVICES .env | cut -d '=' -f2)

[ -z "$VERSION" ] && VERSION=$FONOSTER_LATEST_VERSION
[ -z "$COMPOSE_PROJECT_VERSION" ] && error "Could not get the current version of Fonoster application."

info "Stop Fonoster application... 🚨 "
execute "bash ./basic-network.sh down"

}
4 changes: 4 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ source "$HELPERS/set-env.sh"
# Commands sources
source "$COMMANDS/install.sh"
source "$COMMANDS/update.sh"
source "$COMMANDS/stop.sh"

INPUT=$1
shift
Expand All @@ -40,6 +41,9 @@ install | setup | init | start)
upgrade | update)
update "$@"
;;
stop)
stop "$@"
;;
*)
error "Unknown command: $COMMAND"
;;
Expand Down
3 changes: 3 additions & 0 deletions etc/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

/docker/run.sh stop

0 comments on commit 68cb1fa

Please sign in to comment.