Skip to content

Commit 38dd919

Browse files
Merge pull request #19 from frmscoe/dockerize
feat: add dockerfile, service.yml and deployment.yml files to auth se…
2 parents bc5e469 + 0d12099 commit 38dd919

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
*/node_modules
3+
coverage
4+
template
5+
.vscode
6+
README.md

Dockerfile

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
ARG BUILD_IMAGE=node:20-bullseye
3+
ARG RUN_IMAGE=gcr.io/distroless/nodejs20-debian11:nonroot
4+
5+
FROM ${BUILD_IMAGE} AS builder
6+
LABEL stage=build
7+
# TS -> JS stage
8+
9+
WORKDIR /home/app
10+
COPY ./src ./src
11+
COPY ./package*.json ./
12+
COPY ./tsconfig.json ./
13+
COPY .npmrc ./
14+
ARG GH_TOKEN
15+
16+
RUN npm ci --ignore-scripts
17+
RUN npm run build
18+
19+
FROM ${BUILD_IMAGE} AS dep-resolver
20+
LABEL stage=pre-prod
21+
# To filter out dev dependencies from final build
22+
23+
COPY package*.json ./
24+
COPY .npmrc ./
25+
ARG GH_TOKEN
26+
RUN npm ci --omit=dev --ignore-scripts
27+
28+
FROM ${RUN_IMAGE} AS run-env
29+
USER nonroot
30+
31+
WORKDIR /home/app
32+
COPY --from=dep-resolver /node_modules ./node_modules
33+
COPY --from=builder /home/app/build ./build
34+
COPY package.json ./
35+
COPY deployment.yaml ./
36+
COPY service.yaml ./
37+
38+
# Turn down the verbosity to default level.
39+
ENV NPM_CONFIG_LOGLEVEL warn
40+
41+
ENV mode="http"
42+
ENV upstream_url="http://127.0.0.1:3000"
43+
ENV prefix_logs="false"
44+
ENV FUNCTION_NAME=auth-service
45+
ENV NODE_ENV=production
46+
ENV MAX_CPU=
47+
48+
#Fastify
49+
ENV PORT=3000
50+
ENV HOST=0.0.0.0
51+
52+
#Auth Lib
53+
ENV Auth_URL=http://localhost:8080
54+
ENV KEYCLOAK_REALM=tazama
55+
ENV CERT_PATH=private_key.pem
56+
ENV CLIENT_SECRET=""
57+
ENV CLIENT_ID=""
58+
59+
# Set healthcheck command
60+
HEALTHCHECK --interval=60s CMD [ -e /tmp/.lock ] || exit 1
61+
EXPOSE 3000
62+
63+
# Execute watchdog command
64+
CMD ["build/index.js"]

deployment.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: auth-service-rel-1-0-0
6+
namespace: development
7+
labels:
8+
app: auth-service
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app: auth-service
14+
template:
15+
metadata:
16+
name: auth-service-rel-1-0-0
17+
labels:
18+
app: auth-service
19+
annotations:
20+
prometheus.io.scrape: 'false'
21+
spec:
22+
containers:
23+
- name: auth-service-rel-1-0-0
24+
image: example.io/auth-service-rel-1-0-0:1.0.0
25+
ports:
26+
- name: http
27+
containerPort: 8080
28+
protocol: TCP
29+
resources: {}
30+
imagePullPolicy: Always
31+
restartPolicy: Always
32+
terminationGracePeriodSeconds: 30
33+
dnsPolicy: ClusterFirst
34+
securityContext: {}
35+
imagePullSecrets:
36+
- name: frmpullsecret
37+
schedulerName: default-scheduler
38+
enableServiceLinks: false
39+
strategy:
40+
type: RollingUpdate
41+
rollingUpdate:
42+
maxUnavailable: 0
43+
maxSurge: 1
44+
revisionHistoryLimit: 10
45+
progressDeadlineSeconds: 600

service.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: auth-service-rel-1-0-0
6+
namespace: development
7+
spec:
8+
ports:
9+
- name: http
10+
protocol: TCP
11+
port: 8080
12+
targetPort: 8080
13+
selector:
14+
app: auth-service
15+
type: ClusterIP
16+
sessionAffinity: None
17+
ipFamilies:
18+
- IPv4
19+
ipFamilyPolicy: SingleStack
20+
internalTrafficPolicy: Cluster

0 commit comments

Comments
 (0)