Skip to content

Commit b8b6db5

Browse files
committed
Merge branch 'upstream'
2 parents a4776df + 2cd3d55 commit b8b6db5

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

docker-compose-javaworker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414

1515
result:
1616
build: ./result
17-
command: nodemon --debug server.js
17+
command: nodemon server.js
1818
volumes:
1919
- ./result:/app
2020
ports:

result/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
FROM node:8.9-slim
1+
FROM node:8.9-alpine
22

3+
RUN mkdir -p /app
34
WORKDIR /app
45

56
RUN npm install -g nodemon
6-
ADD package.json /app/package.json
7-
RUN npm config set registry http://registry.npmjs.org
8-
RUN npm install && npm ls
9-
RUN mv /app/node_modules /node_modules
10-
11-
ADD . /app
7+
RUN npm config set registry https://registry.npmjs.org
8+
COPY package.json /app/package.json
9+
RUN npm install \
10+
&& npm ls \
11+
&& npm cache clean --force \
12+
&& mv /app/node_modules /node_modules
13+
COPY . /app
1214

1315
ENV PORT 80
1416
EXPOSE 80

result/tests/tests.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#!/bin/sh
2-
while ! timeout 1 bash -c "echo > /dev/tcp/vote/80"; do sleep 1; done
2+
3+
while ! timeout 1 bash -c "echo > /dev/tcp/vote/80"; do
4+
sleep 1
5+
done
6+
37
curl -sS -X POST --data "vote=b" http://vote > /dev/null
48
sleep 10
9+
510
if phantomjs render.js http://result | grep -q '1 vote'; then
6-
echo -e "\e[42m------------"
7-
echo -e "\e[92mTests passed"
8-
echo -e "\e[42m------------"
11+
echo -e "\\e[42m------------"
12+
echo -e "\\e[92mTests passed"
13+
echo -e "\\e[42m------------"
914
exit 0
10-
fi
11-
echo -e "\e[41m------------"
12-
echo -e "\e[91mTests failed"
13-
echo -e "\e[41m------------"
15+
else
16+
echo -e "\\e[41m------------"
17+
echo -e "\\e[91mTests failed"
18+
echo -e "\\e[41m------------"
1419
exit 1
20+
fi

worker/Dockerfile.j

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
FROM java:openjdk-8-jdk-alpine
2-
3-
RUN MAVEN_VERSION=3.3.3 \
4-
&& cd /usr/share \
5-
&& wget http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz -O - | tar xzf - \
6-
&& mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
7-
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
1+
FROM maven:3.5-jdk-8-alpine AS build
82

93
WORKDIR /code
104

11-
ADD pom.xml /code/pom.xml
5+
COPY pom.xml /code/pom.xml
126
RUN ["mvn", "dependency:resolve"]
137
RUN ["mvn", "verify"]
148

159
# Adding source, compile and package into a fat jar
16-
ADD src/main /code/src/main
10+
COPY ["src/main", "/code/src/main"]
1711
RUN ["mvn", "package"]
1812

19-
CMD ["java", "-jar", "target/worker-jar-with-dependencies.jar"]
13+
FROM openjdk:8-jre-alpine
14+
15+
COPY --from=build /code/target/worker-jar-with-dependencies.jar /
16+
17+
CMD ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-jar", "/worker-jar-with-dependencies.jar"]

0 commit comments

Comments
 (0)