Skip to content

Commit e100278

Browse files
committed
First commit for templated Dockerfiles
Signed-off-by: Kaur Palang <[email protected]>
1 parent 8f656d4 commit e100278

File tree

6 files changed

+177
-0
lines changed

6 files changed

+177
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!entrypoint.sh
File renamed without changes.

releases.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Specifies which slug should gain the "latest" tags
2+
latest: 4.5.2-tp.1
3+
4+
# Sets the alpine image tag for the downloader stage
5+
downloaderTag: 3.21.3
6+
7+
uid: 1000
8+
gid: 1000
9+
10+
# Add OCI best-practice labels https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
11+
labels: |-
12+
"org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \
13+
"org.opencontainers.image.created"="${CREATED_AT?:}" \
14+
"org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \
15+
"org.opencontainers.image.licenses"="MPL-2.0" \
16+
"org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \
17+
"org.opencontainers.image.title"="Open Integration Engine" \
18+
"org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \
19+
"org.opencontainers.image.vendor"="The Open Integration Engine Project" \
20+
"org.opencontainers.image.version"="{{ .slug }}"
21+
22+
versions:
23+
- slug: 4.5.2-tp.1
24+
releaseVersion: 4.5.2
25+
releaseUrl: https://github.com/OpenIntegrationEngine/engine/releases/download/v4.5.2-tp.1/oie_unix_4_5_2.tar.gz
26+
tags:
27+
- distro: ubuntu
28+
type: jre
29+
tag: 17.0.15_6-jre-noble
30+
- distro: ubuntu
31+
type: jdk
32+
tag: 17.0.15_6-jdk-noble
33+
- distro: alpine
34+
type: jre
35+
tag: 17.0.15_6-jre-alpine
36+
- distro: alpine
37+
type: jdk
38+
tag: 17.0.15_6-jdk-alpine

render_docker_images.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Render Dockerfiles
2+
gomplate -V -c .=releases.yaml -f templates/Dockerfile.tpl
3+
4+
# Render compose files
5+
gomplate -V -c .=releases.yaml -f templates/compose.yaml.tpl

templates/Dockerfile.tpl

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{{/* Collect all root elements except "versions" into a variable */}}
2+
{{- $config := coll.Omit "versions" . -}}
3+
4+
{{/* Create gomplate specific iteration over versions array */}}
5+
{{- range $version := .versions -}}
6+
{{- $ctx := dict "config" $config "version" $version }}
7+
8+
{{/* Define paths to render the Dockerfiles to */}}
9+
{{- $outPath := printf "dockerfiles/%s/Dockerfile" $version.slug }}
10+
11+
{{/* Render the inline template defined below */}}
12+
{{- tmpl.Exec "dockerfile" $ctx | file.Write $outPath }}
13+
{{- end -}}
14+
15+
{{- define "dockerfile" -}}
16+
# syntax=docker/dockerfile:1
17+
18+
################################################################
19+
# #
20+
# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY #
21+
# #
22+
################################################################
23+
24+
ARG CREATED_AT
25+
26+
FROM alpine:{{ .config.downloaderTag }} AS downloader
27+
28+
WORKDIR /opt
29+
30+
# Download Open Integration Engine release
31+
RUN apk add --no-cache curl \
32+
&& curl -L \
33+
-o /opt/engine.tar.gz \
34+
-H "Accept: application/vnd.github+json" \
35+
-H "X-GitHub-Api-Version: 2022-11-28" \
36+
{{ .version.releaseUrl }} \
37+
&& tar xzf engine.tar.gz \
38+
&& mv /opt/oie /opt/engine \
39+
&& mkdir -p /opt/engine/appdata
40+
41+
WORKDIR /opt/engine
42+
COPY --chmod=755 entrypoint.sh /opt/engine/entrypoint.sh
43+
44+
RUN rm -rf cli-lib manager-lib \
45+
&& rm mirth-cli-launcher.jar oiecommand
46+
47+
RUN chown -R {{ $.config.uid }}:{{ $.config.gid }} /opt/engine
48+
49+
{{- /* Assign current version slug into a variable to carry it into the tags iteration */}}
50+
{{- $slug := dict "slug" .version.slug -}}
51+
{{/* Iterate version tags to generate the final stages */}}
52+
{{- range .version.tags }}
53+
FROM eclipse-temurin:{{ .tag }} AS {{ print .distro "-" .type }}
54+
55+
ARG CREATED_AT
56+
57+
LABEL \
58+
{{/* Render the Labels section to include the slug */}}
59+
{{- tpl $.config.labels $slug | strings.Indent 2 }}
60+
61+
COPY --from=downloader /opt/engine /opt/engine
62+
{{ if eq .distro "ubuntu" }}
63+
RUN apt-get update \
64+
&& apt-get install -y unzip \
65+
&& rm -rf /var/lib/apt/lists/* \
66+
&& groupmod --new-name engine ubuntu \
67+
&& usermod -l engine ubuntu \
68+
&& usermod -aG engine engine
69+
{{- else if eq .distro "alpine" }}
70+
RUN apk add --no-cache bash unzip \
71+
&& adduser -D -H -u {{ $.config.uid }} engine engine
72+
{{- end }}
73+
74+
VOLUME /opt/engine/appdata
75+
VOLUME /opt/engine/custom-extensions
76+
77+
WORKDIR /opt/engine
78+
EXPOSE 8443
79+
USER engine
80+
81+
ENTRYPOINT ["./entrypoint.sh"]
82+
CMD ["./oieserver"]
83+
{{ end -}}
84+
85+
{{ end }}

templates/compose.yaml.tpl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{/* Create gomplate specific iteration over versions array */}}
2+
{{- range $version := .versions -}}
3+
{{- $ctx := dict "latest" $.latest "version" $version }}
4+
5+
{{/* Define paths to render the Dockerfiles to */}}
6+
{{- $outPath := printf "dockerfiles/%s/compose.yaml" $version.slug }}
7+
8+
{{/* Render the inline template defined below */}}
9+
{{- tmpl.Exec "composefile" $ctx | file.Write $outPath }}
10+
{{- end -}}
11+
12+
{{- define "composefile" -}}
13+
################################################################
14+
# #
15+
# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY #
16+
# #
17+
################################################################
18+
19+
name: open-integration-engine
20+
21+
{{/* Assign current version slug into a variable to carry it into the tags iteration */}}
22+
{{- $slug := .version.slug -}}
23+
services:
24+
{{- range .version.tags }}
25+
{{ print .distro "-" .type ":" }}
26+
image: openintegrationengine/engine
27+
build:
28+
dockerfile: dockerfiles/{{ $slug }}/Dockerfile
29+
target: {{ .distro }}-{{ .type }}
30+
context: ../../
31+
platforms:
32+
- linux/amd64
33+
# - linux/arm64
34+
tags:
35+
- openintegrationengine/engine:{{ $slug }}-{{ .distro }}
36+
- openintegrationengine/engine:{{ $slug }}-{{ .distro }}-{{ .type }}
37+
{{- if eq $slug $.latest }}
38+
- openintegrationengine/engine:latest-{{ .distro }}-{{ .type }}
39+
{{- if eq .type "jre" }}
40+
- openintegrationengine/engine:latest-{{ .distro }}
41+
{{- if eq .distro "alpine" }}
42+
- openintegrationengine/engine:latest
43+
{{- end }}
44+
{{- end }}
45+
{{- end }}
46+
{{ end }}
47+
{{- end }}

0 commit comments

Comments
 (0)