-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDockerfile
118 lines (78 loc) Β· 2.97 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Use maven as base image
FROM maven:3.8.3-openjdk-17
# Copy the entire maven project
COPY . /build/
# Set working directory
WORKDIR /build
# Generate the rsa keys
RUN microdnf install -y openssl
RUN openssl genrsa -out keypair.pem 2048
RUN openssl rsa -in keypair.pem -pubout -out public.pem
RUN openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out private.pem
# Copy the private key and public key to identity microservice to sign JWT
RUN mkdir -p /build/Identity/src/main/resources/certs
RUN cp private.pem /build/Identity/src/main/resources/certs/private.pem
RUN cp public.pem /build/Identity/src/main/resources/certs/public.pem
# Copy the public key to api gateway to verify JWT
RUN mkdir -p /build/ApiGateway/src/main/resources/certs
RUN cp public.pem /build/ApiGateway/src/main/resources/certs/public.pem
# Build the project
RUN mvn clean package -DskipTests
# specify targets for each microservice
# ApiGateway
# Use lightweight jre as base image
FROM bellsoft/liberica-runtime-container:jre-17-slim-musl AS api-gateway
# Copy only the jar file
COPY --from=0 /build/ApiGateway/target/apigateway-1.0-SNAPSHOT.jar apigateway.jar
# Run the jar file
ENTRYPOINT ["java","-jar","apigateway.jar"]
# Cart
# Use lightweight jre as base image
FROM bellsoft/liberica-runtime-container:jre-17-slim-musl AS cart
# Copy only the jar file
COPY --from=0 /build/Cart/target/cart-1.0-SNAPSHOT.jar cart.jar
# Run the jar file
ENTRYPOINT ["java","-jar","cart.jar"]
# Identity
# Use lightweight jre as base image
FROM bellsoft/liberica-runtime-container:jre-17-slim-musl AS identity
# Copy only the jar file
COPY --from=0 /build/Identity/target/identity-1.0-SNAPSHOT.jar identity.jar
# Run the jar file
ENTRYPOINT ["java","-jar","identity.jar"]
# Order
# Use lightweight jre as base image
FROM bellsoft/liberica-runtime-container:jre-17-slim-musl AS order
# Copy only the jar file
COPY --from=0 /build/Order/target/order-1.0-SNAPSHOT.jar order.jar
# Run the jar file
ENTRYPOINT ["java","-jar","order.jar"]
# Product
# Use lightweight jre as base image
FROM bellsoft/liberica-runtime-container:jre-17-slim-musl AS product
# Copy only the jar file
COPY --from=0 /build/Product/target/product-1.0-SNAPSHOT.jar product.jar
# Run the jar file
ENTRYPOINT ["java","-jar","product.jar"]
# Payment
# Use lightweight python image as base image
FROM python:3.10-alpine AS payment
# make sure all messages always reach console
ENV PYTHONUNBUFFERED=1
# prevent writing bytecode
ENV PYTHONDONTWRITEBYTECODE=1
# Copy the entire python project
COPY Payment /Payment
# Set working directory
WORKDIR /Payment
# Install dependencies
RUN pip install -r requirements.txt
# Run the python file
ENTRYPOINT ["python", "app.py"]
# Fluentd
FROM fluent/fluentd:v1.12.0-debian-1.0 AS fluentd
USER root
RUN gem install excon -v 0.109.0
RUN gem uninstall -I elasticsearch && gem install elasticsearch -v 7.13.3
RUN ["gem", "install", "fluent-plugin-elasticsearch", "--no-document", "--version", "5.0.3"]
USER fluent