diff --git a/application/jaxrs-activemq-quarkus/src/test/java/webapp/tier/service/socket/ActiveMqSocketTest.java b/application/jaxrs-activemq-quarkus/src/test/java/webapp/tier/service/socket/ActiveMqSocketTest.java index 9a77710f2..c9d4be97d 100644 --- a/application/jaxrs-activemq-quarkus/src/test/java/webapp/tier/service/socket/ActiveMqSocketTest.java +++ b/application/jaxrs-activemq-quarkus/src/test/java/webapp/tier/service/socket/ActiveMqSocketTest.java @@ -1,8 +1,9 @@ package webapp.tier.service.socket; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import javax.inject.Inject; import javax.websocket.RemoteEndpoint; @@ -24,7 +25,7 @@ class ActiveMqSocketTest { @Test void testOnOpen() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -36,7 +37,7 @@ void testOnOpen() { @Test void testOnClose() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -49,7 +50,7 @@ void testOnClose() { @Test void testOnError() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -62,9 +63,9 @@ void testOnError() { @Test void testOnMessage() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { - RemoteEndpoint.Async async = Mockito.mock(RemoteEndpoint.Async.class); + RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class); Mockito.when(session.getId()).thenReturn(id); Mockito.when(session.getAsyncRemote()).thenReturn(async); socket.onOpen(session); diff --git a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/healthcheck/ReadinessHealthCheckHazelcastTest.java b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/healthcheck/ReadinessHealthCheckHazelcastTest.java index 46ca39e4b..1ce9c87d1 100644 --- a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/healthcheck/ReadinessHealthCheckHazelcastTest.java +++ b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/healthcheck/ReadinessHealthCheckHazelcastTest.java @@ -3,6 +3,7 @@ import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.*; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import java.io.IOException; import java.util.concurrent.TimeoutException; @@ -27,7 +28,7 @@ void testCallDown() { void testCallUp() throws IOException, TimeoutException { ReadinessHealthCheckHazelcast hc = new ReadinessHealthCheckHazelcast() { protected HazelcastServiceStatus createHazelcastStatus() { - HazelcastServiceStatus mock = Mockito.mock(HazelcastServiceStatus.class); + HazelcastServiceStatus mock = mock(HazelcastServiceStatus.class); Mockito.when(mock.isActive()).thenReturn(true); return mock; } diff --git a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastCacheServiceTest.java b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastCacheServiceTest.java index 7566a4122..d033e7533 100644 --- a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastCacheServiceTest.java +++ b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastCacheServiceTest.java @@ -1,11 +1,9 @@ package webapp.tier.service; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.when; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import java.io.IOException; import java.security.NoSuchAlgorithmException; @@ -20,7 +18,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; -import org.mockito.Mockito; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; @@ -58,7 +55,7 @@ void testPutMsgHazelcast() throws NoSuchAlgorithmException { @Test void testPutMsgHazelcastError() { - HazelcastInstance mockInstanceError = Mockito.mock(HazelcastInstance.class); + HazelcastInstance mockInstanceError = mock(HazelcastInstance.class); when(mockInstanceError.getMap(ArgumentMatchers.any())) .thenThrow(new IllegalStateException()); try { @@ -85,7 +82,7 @@ void testGetMsgHazelcast() { @Test void testGetMsgHazelcastError() { - HazelcastInstance mockInstanceError = Mockito.mock(HazelcastInstance.class); + HazelcastInstance mockInstanceError = mock(HazelcastInstance.class); when(mockInstanceError.getMap(ArgumentMatchers.any())) .thenThrow(new IllegalStateException()); try { diff --git a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastMqServiceTest.java b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastMqServiceTest.java index 38a6400e4..ec0a9781f 100644 --- a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastMqServiceTest.java +++ b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/HazelcastMqServiceTest.java @@ -1,11 +1,9 @@ package webapp.tier.service; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.Mockito.when; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import java.io.IOException; import java.security.NoSuchAlgorithmException; @@ -18,7 +16,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; -import org.mockito.Mockito; import com.hazelcast.collection.IQueue; import com.hazelcast.core.Hazelcast; @@ -63,7 +60,7 @@ void testPutQueueHazelcast() { @Test void testPutQueueHazelcastError() { - HazelcastInstance mockInstanceError = Mockito.mock(HazelcastInstance.class); + HazelcastInstance mockInstanceError = mock(HazelcastInstance.class); when(mockInstanceError.getQueue(ArgumentMatchers.any())) .thenThrow(new IllegalStateException()); assertThat(svc.putMsg(mockInstanceError).getFullmsg(), containsString(respbody)); @@ -96,7 +93,7 @@ void testGetQueueHazelcast() throws NoSuchAlgorithmException, InterruptedExcepti @Test void testGetQueueHazelcastError() { - HazelcastInstance mockInstanceError = Mockito.mock(HazelcastInstance.class); + HazelcastInstance mockInstanceError = mock(HazelcastInstance.class); when(mockInstanceError.getQueue(ArgumentMatchers.any())) .thenThrow(new IllegalStateException()); assertThat(svc.getMsg(mockInstanceError).getMessage(), is("Unexpected Error")); @@ -105,8 +102,8 @@ void testGetQueueHazelcastError() { @SuppressWarnings("unchecked") @Test void testGetQueueHazelcastObjectNullError() { - HazelcastInstance mocknull = Mockito.mock(HazelcastInstance.class); - IQueue mockqueue = Mockito.mock(IQueue.class); + HazelcastInstance mocknull = mock(HazelcastInstance.class); + IQueue mockqueue = mock(IQueue.class); when(mocknull.getQueue(ArgumentMatchers.any())).thenReturn(mockqueue); when(mockqueue.poll()).thenReturn(null); assertThat(svc.getMsg(mocknull).getFullmsg(), containsString("No Data.")); @@ -115,8 +112,8 @@ void testGetQueueHazelcastObjectNullError() { @SuppressWarnings("unchecked") @Test void testGetQueueHazelcastObjectEmptyError() { - HazelcastInstance mocknull = Mockito.mock(HazelcastInstance.class); - IQueue mockqueue = Mockito.mock(IQueue.class); + HazelcastInstance mocknull = mock(HazelcastInstance.class); + IQueue mockqueue = mock(IQueue.class); when(mocknull.getQueue(ArgumentMatchers.any())).thenReturn(mockqueue); when(mockqueue.poll()).thenReturn(""); assertThat(svc.getMsg(mocknull).getFullmsg(), containsString("No Data.")); @@ -142,7 +139,7 @@ void testPublishHazelcast() { @Test void testPublishHazelcastError() { - HazelcastInstance mockInstanceError = Mockito.mock(HazelcastInstance.class); + HazelcastInstance mockInstanceError = mock(HazelcastInstance.class); when(mockInstanceError.getTopic(ArgumentMatchers.any())) .thenThrow(new IllegalStateException()); assertThat(svc.publishMsg(mockInstanceError).getFullmsg(), diff --git a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/socket/HazelcastSocketTest.java b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/socket/HazelcastSocketTest.java index dca5497dc..d88a6f9b8 100644 --- a/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/socket/HazelcastSocketTest.java +++ b/application/jaxrs-hazelcast-quarkus/src/test/java/webapp/tier/service/socket/HazelcastSocketTest.java @@ -1,8 +1,9 @@ package webapp.tier.service.socket; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import javax.inject.Inject; import javax.websocket.RemoteEndpoint; @@ -24,7 +25,7 @@ class HazelcastSocketTest { @Test void testOnOpen() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -36,7 +37,7 @@ void testOnOpen() { @Test void testOnClose() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -49,7 +50,7 @@ void testOnClose() { @Test void testOnError() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -62,9 +63,9 @@ void testOnError() { @Test void testOnMessage() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { - RemoteEndpoint.Async async = Mockito.mock(RemoteEndpoint.Async.class); + RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class); Mockito.when(session.getId()).thenReturn(id); Mockito.when(session.getAsyncRemote()).thenReturn(async); socket.onOpen(session); diff --git a/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/resource/MemcachedResourceTest.java b/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/resource/MemcachedResourceTest.java index 32bdd2b32..f4f8f70fa 100644 --- a/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/resource/MemcachedResourceTest.java +++ b/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/resource/MemcachedResourceTest.java @@ -1,13 +1,13 @@ package webapp.tier.resource; -import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.containsString; +import static io.restassured.RestAssured.*; +import static org.hamcrest.Matchers.*; +import static org.mockito.Mockito.*; import static org.mockito.Mockito.when; import java.security.NoSuchAlgorithmException; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; import com.whalin.MemCached.MemCachedClient; @@ -25,7 +25,7 @@ class MemcachedResourceTest { @Test void testSet() throws NoSuchAlgorithmException, RuntimeException { - MemCachedClient mcc = Mockito.mock(MemCachedClient.class); + MemCachedClient mcc = mock(MemCachedClient.class); MsgBean msgbean = new MsgBean(CreateId.createid(), "test", "Test"); when(svc.createMemCachedClient()).thenReturn(mcc); when(svc.setMsg(mcc)).thenReturn(msgbean); @@ -40,7 +40,7 @@ void testSet() throws NoSuchAlgorithmException, RuntimeException { @Test void testGet() throws NoSuchAlgorithmException { - MemCachedClient mcc = Mockito.mock(MemCachedClient.class); + MemCachedClient mcc = mock(MemCachedClient.class); MsgBean msgbean = new MsgBean(CreateId.createid(), "test", "Test"); when(svc.createMemCachedClient()).thenReturn(mcc); when(svc.getMsg(mcc)).thenReturn(msgbean); diff --git a/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/service/MemcachedServiceTest.java b/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/service/MemcachedServiceTest.java index 95a334b6a..a97bfbf10 100644 --- a/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/service/MemcachedServiceTest.java +++ b/application/jaxrs-memcached-quarkus/src/test/java/webapp/tier/service/MemcachedServiceTest.java @@ -3,6 +3,7 @@ import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.*; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import javax.inject.Inject; @@ -25,7 +26,7 @@ class MemcachedServiceTest { @Test void testSetMemcached() { - MemCachedClient mcc = Mockito.mock(MemCachedClient.class); + MemCachedClient mcc = mock(MemCachedClient.class); Mockito.when(mcc.set(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(true); try { MsgBean msgbean = svcMock.setMsg(mcc); @@ -51,7 +52,7 @@ void testSetMemcachedError() { void testGetMemcached() { Object obj = "11111111"; String msg = "Hello k8s-3tier-webapp with quarkus"; - MemCachedClient mcc = Mockito.mock(MemCachedClient.class); + MemCachedClient mcc = mock(MemCachedClient.class); Mockito.when(mcc.get("id")).thenReturn(obj.toString()); Mockito.when(mcc.get("msg")).thenReturn(msg); diff --git a/application/jaxrs-mongodb-quarkus/src/test/java/webapp/tier/service/MongodbServiceTest.java b/application/jaxrs-mongodb-quarkus/src/test/java/webapp/tier/service/MongodbServiceTest.java index 7f8e041db..4ba2b7407 100644 --- a/application/jaxrs-mongodb-quarkus/src/test/java/webapp/tier/service/MongodbServiceTest.java +++ b/application/jaxrs-mongodb-quarkus/src/test/java/webapp/tier/service/MongodbServiceTest.java @@ -35,7 +35,7 @@ class MongodbServiceTest { @Test @SuppressWarnings("unchecked") void testInsertMysql() throws NoSuchAlgorithmException { - MongoCollection col = Mockito.mock(MongoCollection.class); + MongoCollection col = mock(MongoCollection.class); when(col.insertOne(ArgumentMatchers.any())).thenReturn(null); assertThat(mongosvc.insertMsg(col).getFullmsg(), containsString(respbody)); } @@ -43,9 +43,9 @@ void testInsertMysql() throws NoSuchAlgorithmException { @Test @SuppressWarnings("unchecked") void testSelectMsgIsEmpty() { - MongoCursor cursor = Mockito.mock(MongoCursor.class); - FindIterable ite = Mockito.mock(FindIterable.class); - MongoCollection col = Mockito.mock(MongoCollection.class); + MongoCursor cursor = mock(MongoCursor.class); + FindIterable ite = mock(FindIterable.class); + MongoCollection col = mock(MongoCollection.class); when(col.find()).thenReturn(ite); when(ite.iterator()).thenReturn(cursor); mongosvc.selectMsg(col); @@ -58,9 +58,9 @@ void testSelectMsgWithMessage() { map.put("id", 1111); map.put("msg", "Test"); Document document = new Document(map); - MongoCursor cursor = Mockito.mock(MongoCursor.class); - FindIterable ite = Mockito.mock(FindIterable.class); - MongoCollection col = Mockito.mock(MongoCollection.class); + MongoCursor cursor = mock(MongoCursor.class); + FindIterable ite = mock(FindIterable.class); + MongoCollection col = mock(MongoCollection.class); when(cursor.hasNext()).thenReturn(true).thenReturn(false); when(cursor.next()).thenReturn(document); when(ite.iterator()).thenReturn(cursor); @@ -75,7 +75,7 @@ void testSelectMsgWithMessage() { @Test @SuppressWarnings("unchecked") void testDeleteMsg() { - MongoCollection col = Mockito.mock(MongoCollection.class); + MongoCollection col = mock(MongoCollection.class); when(col.insertOne(ArgumentMatchers.any())).thenReturn(null); assertThat(mongosvc.deleteMsg(col), is("Delete Msg Collection")); } diff --git a/application/jaxrs-rabbitmq-quarkus/src/test/java/webapp/tier/service/socket/RabbitmqSocketTest.java b/application/jaxrs-rabbitmq-quarkus/src/test/java/webapp/tier/service/socket/RabbitmqSocketTest.java index 2263fabbf..4f1f3492c 100644 --- a/application/jaxrs-rabbitmq-quarkus/src/test/java/webapp/tier/service/socket/RabbitmqSocketTest.java +++ b/application/jaxrs-rabbitmq-quarkus/src/test/java/webapp/tier/service/socket/RabbitmqSocketTest.java @@ -1,8 +1,9 @@ package webapp.tier.service.socket; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import javax.inject.Inject; import javax.websocket.RemoteEndpoint; @@ -24,7 +25,7 @@ class RabbitmqSocketTest { @Test void testOnOpen() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -36,7 +37,7 @@ void testOnOpen() { @Test void testOnClose() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -49,7 +50,7 @@ void testOnClose() { @Test void testOnError() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -62,9 +63,9 @@ void testOnError() { @Test void testOnMessage() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { - RemoteEndpoint.Async async = Mockito.mock(RemoteEndpoint.Async.class); + RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class); Mockito.when(session.getId()).thenReturn(id); Mockito.when(session.getAsyncRemote()).thenReturn(async); socket.onOpen(session); diff --git a/application/webapp-service/src/test/java/webapp/tier/service/socket/ServiceSocketTest.java b/application/webapp-service/src/test/java/webapp/tier/service/socket/ServiceSocketTest.java index 940cdcc12..f2a21eae7 100644 --- a/application/webapp-service/src/test/java/webapp/tier/service/socket/ServiceSocketTest.java +++ b/application/webapp-service/src/test/java/webapp/tier/service/socket/ServiceSocketTest.java @@ -1,8 +1,9 @@ package webapp.tier.service.socket; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; import javax.inject.Inject; import javax.websocket.RemoteEndpoint; @@ -24,7 +25,7 @@ class ServiceSocketTest { @Test void testOnOpen() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -36,7 +37,7 @@ void testOnOpen() { @Test void testOnClose() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -49,7 +50,7 @@ void testOnClose() { @Test void testOnError() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { Mockito.when(session.getId()).thenReturn(id); socket.onOpen(session); @@ -62,9 +63,9 @@ void testOnError() { @Test void testOnMessage() { - Session session = Mockito.mock(Session.class); + Session session = mock(Session.class); try { - RemoteEndpoint.Async async = Mockito.mock(RemoteEndpoint.Async.class); + RemoteEndpoint.Async async = mock(RemoteEndpoint.Async.class); Mockito.when(session.getId()).thenReturn(id); Mockito.when(session.getAsyncRemote()).thenReturn(async); socket.onOpen(session); diff --git a/kubernetes/cassandra/Dockerfile b/kubernetes/cassandra/Dockerfile index 5cb56bd09..1633b49cc 100644 --- a/kubernetes/cassandra/Dockerfile +++ b/kubernetes/cassandra/Dockerfile @@ -3,6 +3,8 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/yurake/k8s-3tier-webapp" +USER cassandra +WORKDIR /opt/cassandra COPY entrypoint-wrap.sh / COPY init /docker-entrypoint-initdb.d ENTRYPOINT ["/entrypoint-wrap.sh"] diff --git a/kubernetes/mongodb/Dockerfile b/kubernetes/mongodb/Dockerfile index e51a87ebe..6fa49a34e 100644 --- a/kubernetes/mongodb/Dockerfile +++ b/kubernetes/mongodb/Dockerfile @@ -3,4 +3,5 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/yurake/k8s-3tier-webapp" +USER mongodb COPY init /docker-entrypoint-initdb.d diff --git a/kubernetes/monitoring/test/postmannewman/quarkus/Dockerfile b/kubernetes/monitoring/test/postmannewman/quarkus/Dockerfile index 8bb3f77cb..5d115ec04 100644 --- a/kubernetes/monitoring/test/postmannewman/quarkus/Dockerfile +++ b/kubernetes/monitoring/test/postmannewman/quarkus/Dockerfile @@ -3,5 +3,7 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/yurake/k8s-3tier-webapp" +RUN addgroup -S newman && adduser -S newman -G newman +USER newman COPY hostname-quarkus.postman_environment.json /etc/newman/ COPY jaxrs-quarkus.postman_collection.json /etc/newman/ diff --git a/kubernetes/mysql/Dockerfile b/kubernetes/mysql/Dockerfile index de9ffc796..6fd6cdf98 100644 --- a/kubernetes/mysql/Dockerfile +++ b/kubernetes/mysql/Dockerfile @@ -3,4 +3,5 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/yurake/k8s-3tier-webapp" -COPY init /docker-entrypoint-initdb.d \ No newline at end of file +USER mysql +COPY init /docker-entrypoint-initdb.d diff --git a/kubernetes/nginx/Dockerfile b/kubernetes/nginx/Dockerfile index 1c98a3118..6de0c2e24 100644 --- a/kubernetes/nginx/Dockerfile +++ b/kubernetes/nginx/Dockerfile @@ -4,5 +4,21 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/yurake/k8s-3tier-webapp" + COPY default.conf /etc/nginx/conf.d/default.conf COPY docs /etc/nginx/docs + +# Implement changes required to run NGINX as an unprivileged user +RUN sed -i '/user nginx;/d' /etc/nginx/nginx.conf \ + && sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \ + && sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n \ + client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n \ + uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \ + # Nginx user must own the cache and etc directory to write cache and tweak the nginx config + && chown -R nginx:nginx /var/cache/nginx \ + && chmod -R g+w /var/cache/nginx \ + && chown -R nginx:nginx /etc/nginx \ + && chmod -R g+w /etc/nginx + +EXPOSE 8080 +USER nginx diff --git a/kubernetes/nginx/default.conf b/kubernetes/nginx/default.conf index f9b68c490..28c75b5b3 100644 --- a/kubernetes/nginx/default.conf +++ b/kubernetes/nginx/default.conf @@ -1,6 +1,6 @@ server { - listen 80; + listen 8080; server_name localhost; root /etc/nginx/docs; diff --git a/kubernetes/nginx/nginx-deployment.yaml b/kubernetes/nginx/nginx-deployment.yaml index 59cf60d9c..bd08547f2 100644 --- a/kubernetes/nginx/nginx-deployment.yaml +++ b/kubernetes/nginx/nginx-deployment.yaml @@ -22,10 +22,10 @@ spec: image: yurak/nginx:latest imagePullPolicy: Always ports: - - containerPort: 80 + - containerPort: 8080 livenessProbe: tcpSocket: - port: 80 + port: 8080 readinessProbe: httpGet: port: 9113 diff --git a/kubernetes/nginx/nginx-service.yaml b/kubernetes/nginx/nginx-service.yaml index e056d6a93..b5591ca8a 100644 --- a/kubernetes/nginx/nginx-service.yaml +++ b/kubernetes/nginx/nginx-service.yaml @@ -8,4 +8,4 @@ spec: app: nginx ports: - protocol: TCP - port: 80 + port: 8080 diff --git a/kubernetes/postgres/Dockerfile b/kubernetes/postgres/Dockerfile index 72c4c20a7..72f939c60 100644 --- a/kubernetes/postgres/Dockerfile +++ b/kubernetes/postgres/Dockerfile @@ -3,6 +3,7 @@ ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/yurake/k8s-3tier-webapp" +USER postgres COPY init /docker-entrypoint-initdb.d COPY conf/postgresql.conf /etc/postgresql/postgresql.conf CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"] diff --git a/kubernetes/rabbitmq/Dockerfile b/kubernetes/rabbitmq/Dockerfile index bfccaf029..29fd8e9a3 100644 --- a/kubernetes/rabbitmq/Dockerfile +++ b/kubernetes/rabbitmq/Dockerfile @@ -11,6 +11,8 @@ RUN apk update && \ apk --no-cache add tzdata && \ cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \ apk del tzdata +USER rabbitmq + COPY custom_definitions.json /etc/rabbitmq/ RUN printf 'management.load_definitions = /etc/rabbitmq/custom_definitions.json\n' >> /etc/rabbitmq/rabbitmq.conf && \ rabbitmq-plugins enable rabbitmq_prometheus