Skip to content

Commit

Permalink
build(ui): adapt docker files to portainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommytrg committed Jul 16, 2021
1 parent 9b1838e commit 4b5c66e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.env
.git
test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,6 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*

mongodb_data
55 changes: 26 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@ services:
MONGO_INITDB_ROOT_PASSWORD: $MONGO_INITDB_ROOT_PASSWORD
volumes:
- ./init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh
- mongodb_data_container:/data/db
mongo-express:
image: "mongo-express"
container_name: mongo-express
ports:
- "8081:8081"
depends_on:
- database
environment:
ME_CONFIG_MONGODB_SERVER: database
ME_CONFIG_MONGODB_AUTH_DATABASE: $MONGO_INITDB_DATABASE
ME_CONFIG_MONGODB_AUTH_USERNAME: $MONGO_DATABASE_USERNAME
ME_CONFIG_MONGODB_AUTH_PASSWORD: $MONGO_DATABASE_PASSWORD
ME_CONFIG_BASICAUTH_USERNAME: $ME_CONFIG_BASICAUTH_USERNAME
ME_CONFIG_BASICAUTH_PASSWORD: $ME_CONFIG_BASICAUTH_PASSWORD
ME_CONFIG_MONGODB_ENABLE_ADMIN: "false"
- ./mongodb_data:/data/db

# mongo-express:
# image: "mongo-express"
# container_name: mongo-express
# ports:
# - "8081:8081"
# depends_on:
# - database
# environment:
# ME_CONFIG_MONGODB_SERVER: database
# ME_CONFIG_MONGODB_AUTH_DATABASE: $MONGO_INITDB_DATABASE
# ME_CONFIG_MONGODB_AUTH_USERNAME: $MONGO_DATABASE_USERNAME
# ME_CONFIG_MONGODB_AUTH_PASSWORD: $MONGO_DATABASE_PASSWORD
# ME_CONFIG_BASICAUTH_USERNAME: $ME_CONFIG_BASICAUTH_USERNAME
# ME_CONFIG_BASICAUTH_PASSWORD: $ME_CONFIG_BASICAUTH_PASSWORD
# ME_CONFIG_MONGODB_ENABLE_ADMIN: "false"

api:
image: data-feed-app-api
image: witnet/data-feed-app-api
ports:
- "4000:4000"
links:
- database
depends_on:
depends_on:
- database
environment:
environment:
SERVER_PORT: $SERVER_PORT
DB_HOSTNAME: $DB_HOSTNAME
DB_HOSTNAME: $DB_HOSTNAME
MONGO_PORT: $MONGO_PORT
MONGO_DATABASE_USERNAME: $MONGO_DATABASE_USERNAME
MONGO_DATABASE_PASSWORD: $MONGO_DATABASE_PASSWORD
Expand All @@ -57,15 +57,12 @@ services:
RINKEBY_PROVIDER: $RINKEBY_PROVIDER

ui:
image: data-feed-app-ui
links:
image: witnet/data-feed-app-ui
links:
- api
ports:
- "8080:8080"
depends_on:
depends_on:
- api
environment:
API_ENDPOINT: "http://api:4000"

volumes:
mongodb_data_container:
API_ENDPOINT: "http://api:4000"
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "node dist/index.js",
"test": "jest",
"prepare": "yarn codegen",
"docker:build": "docker build . --no-cache -t data-feed-api --stream"
"docker:build": "docker build . --no-cache -t witnet/data-feed-app-api --stream"
},
"license": "ISC",
"devDependencies": {
Expand Down
4 changes: 0 additions & 4 deletions packages/api/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ MONGO_PORT=27017
MONGO_DATABASE_USERNAME=your_username
MONGO_DATABASE_PASSWORD=your_password
MONGO_INITDB_DATABASE=database
MONGO_INITDB_ROOT_USERNAME=your_admin_username
MONGO_INITDB_ROOT_PASSWORD=your_admin_password
ME_CONFIG_BASICAUTH_USERNAME=your_mongo_express_username
ME_CONFIG_BASICAUTH_PASSWORD=your_mongo_express_password
GOERLI_PROVIDER=https://goerli.infura.io/v3/<TOKEN>
KOVAN_PROVIDER=https://kovan.infura.io/v3/<TOKEN>
RINKEBY_PROVIDER=https://rinkeby.infura.io/v3/<TOKEN>
3 changes: 1 addition & 2 deletions packages/api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export class MongoManager {
async start (uri?: string): Promise<Db | null> {
const mongoDbUri =
uri ||
`mongodb://${process.env.MONGO_DATABASE_USERNAME}:${process.env.MONGO_DATABASE_PASSWORD}@${process.env.DB_HOSTNAME}:${process.env.MONGO_PORT}/${process.env.DB_HOSTNAME}`

`mongodb://${process.env.MONGO_DATABASE_USERNAME}:${process.env.MONGO_DATABASE_PASSWORD}@${process.env.DB_HOSTNAME}:${process.env.MONGO_PORT}`
return this.connect(mongoDbUri, process.env.MONGO_INITDB_DATABASE as string)
}

Expand Down
8 changes: 5 additions & 3 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ async function main () {

const server = await createServer(repositories)

server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`)
})
server
.listen({ host: '0.0.0.0', port: process.env.SERVER_PORT })
.then(({ url }) => {
console.log(`🚀 Server ready at ${url}`)
})
}

main()
3 changes: 1 addition & 2 deletions packages/ui/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
.env
.git
test
readme.md
test
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint:style": "stylelint \"**/*.{vue,css}\" --fix",
"lint": "yarn lint:js && yarn lint:style",
"test": "yarn jest",
"docker:build": "docker build . --no-cache -t data-feed-ui"
"docker:build": "docker build . --no-cache -t witnet/data-feed-app-ui"
},
"dependencies": {
"@fortawesome/free-brands-svg-icons": "^5.15.3",
Expand Down
8 changes: 6 additions & 2 deletions sample.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SERVER_PORT=3100
SERVER_PORT=4000
DB_HOSTNAME=localhost
MONGO_PORT=27017
MONGO_DATABASE_USERNAME=your_username
Expand All @@ -7,4 +7,8 @@ MONGO_INITDB_DATABASE=database
MONGO_INITDB_ROOT_USERNAME=your_admin_username
MONGO_INITDB_ROOT_PASSWORD=your_admin_password
ME_CONFIG_BASICAUTH_USERNAME=your_mongo_express_username
ME_CONFIG_BASICAUTH_PASSWORD=your_mongo_express_password
ME_CONFIG_BASICAUTH_PASSWORD=your_mongo_express_password
GOERLI_PROVIDER=https://goerli.infura.io/v3/<token>
KOVAN_PROVIDER=https://kovan.infura.io/v3/<token>
RINKEBY_PROVIDER=https://rinkeby.infura.io/v3/<token>
API_ENDPOINT="http://api:4000"

0 comments on commit 4b5c66e

Please sign in to comment.