Skip to content

Commit

Permalink
Dockerize the workitem project
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-gudak committed Jan 31, 2025
1 parent 98790f4 commit a8c92a7
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/graal-native-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push workitems
uses: docker/build-push-action@v5
with:
context: ./workitems
push: ${{ github.event_name == 'push' || inputs.publish }}
tags: |
ghcr.io/ihudak/weekplanner-workitems:latest
ghcr.io/ihudak/weekplanner-workitems:${{ env.RELEASE_VERSION }}
ghcr.io/ihudak/weekplanner-workitems:build_${{ github.run_number }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push WebApp
uses: docker/build-push-action@v5
with:
Expand Down
7 changes: 7 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ spec:
name: users-svc
port:
number: 81
- path: /api/workitems/?(.*)
pathType: ImplementationSpecific
backend:
service:
name: workitems-svc
port:
number: 84
- path: /api/test/?(.*)
pathType: ImplementationSpecific
backend:
Expand Down
79 changes: 79 additions & 0 deletions k8s/workitems.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: workitems
namespace: weekplanner
labels:
app: workitems
spec:
replicas: 1
selector:
matchLabels:
app: workitems
template:
metadata:
annotations:
metrics.dynatrace.com/path: /stats/prometheus
metrics.dynatrace.com/port: "15020"
metrics.dynatrace.com/scrape: "true"
metrics.dynatrace.com/secure: "false"
namespace: weekplanner
labels:
app: workitems
app.kubernetes.io/version: 1.2.0
app.kubernetes.io/part-of: WeekPlanner
spec:
containers:
- name: workitems
image: ghcr.io/ihudak/weekplanner-workitems:latest
ports:
- containerPort: 8080
- containerPort: 5005
envFrom:
- configMapRef:
name: weekplanner-configmap
- secretRef:
name: weekplanner-secret
env:
- name: DT_RELEASE_VERSION
valueFrom:
fieldRef:
fieldPath: metadata.labels['app.kubernetes.io/version']
- name: DT_RELEASE_BUILD_VERSION
value: "2024-04-08-21:40:50"
- name: SERVICE_NAME
value: WorkItems
- name: SERVICE_FULL_NAME
value: "$(APP_NAME).$(SERVICE_NAME).$(SVC_SUFFIX)"
- name: OTEL_RESOURCE_ATTRIBUTES
value: "dt.security_context=$(SECURITY_CONTEXT),dt.cost.costcenter=$(COST_CENTER),dt.cost.project=$(COST_PRODUCT),my.resource.attribute=$(MY_ATTR)"
- name: TENANT_URL
value: "https://$(TENANT_ID).$(TENANT_LAYER).$(DT_SRV).com"
resources:
limits:
cpu: 500m
memory: 768Mi
requests:
cpu: 500m
memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
name: workitems-svc
namespace: weekplanner
spec:
selector:
app: workitems
type: ClusterIP # LoadBalancer
ports:
- name: http
port: 84
protocol: TCP
targetPort: 8080
# nodePort: 30008 # comment if ClusterIP
- name: debug
port: 5008
protocol: TCP
targetPort: 5005
# nodePort: 32008 # comment if ClusterIP
22 changes: 22 additions & 0 deletions workitems/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:jammy
LABEL org.opencontainers.image.authors="dec21.eu"

ENV EXECUTABLE=workitems

RUN mkdir -p /opt/app
WORKDIR /opt/app
COPY build/native/nativeCompile/ .
RUN chmod +x "$EXECUTABLE"

RUN apt-get update && \
apt-get install -y curl sed && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT export TENANT_URL=$(echo "$TENANT_URL" | sed -E 's/[ '\$'/'']+\$//') && \
export TENANT_TOKEN=$(curl -X GET "$TENANT_URL"/api/v1/deployment/installer/agent/connectioninfo \
-H "accept: application/json" \
-H "Authorization: Api-Token $OA_TOKEN" | \
grep tenantToken | \
sed s/\ \ \"tenantToken\"\ :\ \"// | sed s/\",//) && \
export DT_AGENT_OPTIONS=tenant=$TENANT_ID,tenantToken=$TENANT_TOKEN,server="$TENANT_URL:443" && \
"./$EXECUTABLE"
14 changes: 14 additions & 0 deletions workitems/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM openjdk:22
MAINTAINER dynatrace.com
RUN mkdir -p /opt/app
ENV JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
ENV DOCKER_VER=1.5.0

ARG JAR_FILE=build/libs/*0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} /opt/app/app.jar

ENTRYPOINT export OTEL_SERVICE_NAME="$SERVICE_FULL_NAME" && \
java -Dotel.service.name=$SERVICE_FULL_NAME -jar /opt/app/app.jar

EXPOSE 8080
EXPOSE 5005
2 changes: 2 additions & 0 deletions workitems/push_docker.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker image build --platform linux/amd64 -t ivangudak096/weekplanner-workitems:latest .
docker push ivangudak096/weekplanner-workitems:latest

0 comments on commit a8c92a7

Please sign in to comment.