Skip to content

Commit

Permalink
update endpoint and yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
devadvocado committed Oct 2, 2019
1 parent cfcb9b0 commit 5fb8704
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
5 changes: 3 additions & 2 deletions api/app/elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ const items = require('../test/items.json')

const elasticsearch = require('elasticsearch')
const client = new elasticsearch.Client({
// hosts: ['http://elasticsearch-loadbalancer:80'],
hosts: ['http://localhost:9200'],
hosts: [`${process.env.ES_HOST || `http://localhost:9200`}`],
maxRetries: 20,
requestTimeout: 3000
})
Expand Down Expand Up @@ -94,8 +93,10 @@ const importData = async () => {
}, (err, response) => {
if (err) {
console.log("Failed Bulk operation", err)
return {}
} else {
console.log("Successfully imported, total items: ", bulk.length)
return {}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion api/app/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const items = require('../test/items.json')

const redis = require("redis")
const client = redis.createClient({
// host: `redis-master`,
host: process.env.REDIS_HOST,
port: 6379,
retry_strategy: function (options) {
if (options.error && options.error.code === 'ECONNREFUSED') {
Expand Down
6 changes: 2 additions & 4 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const redis = require('./app/redis')
redis.importData()
const elastic = require('./app/elastic')
elastic.importData()

const express = require('express')
const app = express()
Expand All @@ -16,10 +14,10 @@ app.use((req, res, next) => {
next()
})

app.get('/upload', (req, res) => {
app.post('/upload', (req, res) => {
redis.importData()
elastic.importData()
console.log('Redis and Elastic data uploaded')
res.end('Files uploaded')
})

app.get('/items', (req, res) => {
Expand Down
19 changes: 12 additions & 7 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
FROM node

FROM node:8-alpine

WORKDIR /usr/src/app
RUN apk update \
&& apk upgrade \
&& apk add bash curl

COPY package*.json ./
ADD . /kuma-demo-app-fe
WORKDIR /kuma-demo-app-fe

RUN npm install
RUN echo Node `node --version` \
&& echo NPM `npm --version`

COPY . .
RUN npm install -g yarn

EXPOSE 8080
RUN yarn

CMD [ "npm", "run", "serve" ]
CMD yarn serve --mode ci
4 changes: 4 additions & 0 deletions loggly/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM docker.elastic.co/logstash/logstash:7.4.0

RUN curl -s -o /usr/share/logstash/logstash-core/lib/log\
stash/outputs/loggly.rb https://raw.githubusercontent.com/psquickitjayant/logstash-output-loggly/master/lib/logstash/outputs/loggly.rb
7 changes: 6 additions & 1 deletion marketplace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ spec:
app: marketplace-api
spec:
containers:
- image: docker.io/kvn0218/marketplace-api:latest
- image: docker.io/kvn0218/marketplace-api:test
name: marketplace-api
env:
- name: ES_HOST
value: "http://elasticsearch-loadbalancer:80"
- name: REDIS_HOST
value: "redis-master"
imagePullPolicy: Always
ports:
- containerPort: 3001

0 comments on commit 5fb8704

Please sign in to comment.