Skip to content

Commit

Permalink
feat(docker): build/run/pull scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jhderojasUVa committed Aug 13, 2022
1 parent 7d1f46d commit 6b0c998
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,24 @@ Response:
2. Run the [analyted-database-todo](https://github.com/jhderojasUVa/analyted-database-todo) docker image (see their documentation)
3. Run a `docker network inspect analyted_network` and check the IP where `sqltodo` is running
4. Change on the `src/index.js` the ip of the server

# Docker login/build/run/pull

For login into Github repository:

- `npm run docker:login`

For building:

- `npm run docker:build`. To build the latest versions
- `npm run docker:build <version>`. To build the a concrete version

For running:

- `npm run docker:run`. To run the latest versions
- `npm run docker:run <version>`. To run the a concrete version

For pulling (**You need to be logged in and with rights to do it**):

- `npm run docker:pull`. To run the latest versions
- `npm run docker:pull <version>`. To run the a concrete version
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"description": "AnalyTED backend in Node example",
"main": "./src/index.js",
"scripts": {
"docker:build": "docker build -t analyted-backend .",
"docker:run": "docker run --name analyted-backend --network analyted_network -p 8080:8080 -d analyted-backend",
"docker:login": "docker login ghcr.io",
"docker:build": "./scripts/docker-build.sh",
"docker:pull": "./scripts/docker-pull.sh",
"docker:run": "./scripts/docker-run.sh",
"server": "node ./src/index.js",
"prepare": "husky install",
"pre-commit": "lint-staged --relative",
Expand Down
11 changes: 11 additions & 0 deletions scripts/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
## Get version
VERSION=$1

# If you don't say the version it will build the latest always
if [ -z "$1" ]
then
docker build -t ghcr.io/analyted-backend:$1 .
else
docker build -t ghcr.io/analyted-backend:latest .
fi
12 changes: 12 additions & 0 deletions scripts/docker-pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
## Get version
VERSION=$1

## This script pulls on container registry
# Remember that you must be login in
if [ -z "$1" ]
then
docker pull ghcr.io/analyted-backend:$1
else
docker pull ghcr.io/analyted-backend:latest
fi
11 changes: 11 additions & 0 deletions scripts/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
## Get version
VERSION=$1

# If you don't say the version it will always run the latest
if [ -z "$1" ]
then
docker run --name analyted-backend --network analyted_network -p 8080:8080 -d ghcr.io/analyted-backend:$1
else
docker run --name analyted-backend --network analyted_network -p 8080:8080 -d ghcr.io/analyted-backend:latest
fi

0 comments on commit 6b0c998

Please sign in to comment.