Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPSEXP-2713: bake images #4

Merged
merged 23 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 16 additions & 72 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,95 +3,39 @@ name: Build, Run and Test Docker Image
on: [push]

jobs:
build-run-test:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
images:
- artifact: alfresco-elasticsearch-live-indexing-metadata
version: 4.0.1
name: alfresco-enterprise-search-metadata
path: search/enterprise/common
classifier: -app.jar
group: org.alfresco
- artifact: alfresco-elasticsearch-live-indexing-path
version: 4.0.1
name: alfresco-enterprise-search-path
path: search/enterprise/common
classifier: -app.jar
group: org.alfresco

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7

- name: Setup .netrc
run: |
echo "machine nexus.alfresco.com" >> ~/.netrc
echo "login ${{ secrets.NEXUS_USERNAME }}" >> ~/.netrc
echo "password ${{ secrets.NEXUS_PASSWORD }}" >> ~/.netrc

- name: Fetch artifacts from nexus
run: ${{ github.workspace }}/scripts/fetch-artifact.sh
working-directory: ${{ github.workspace }}

- name: Set up QEMU
uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # 3.1.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287 # 3.4.0

- name: Login to Docker Hub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # 3.2.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Setup .netrc
run: |
echo "machine nexus.alfresco.com" >> ~/.netrc
echo "login ${{ secrets.NEXUS_USERNAME }}" >> ~/.netrc
echo "password ${{ secrets.NEXUS_PASSWORD }}" >> ~/.netrc

- name: Fetch artifacts from nexus
run: ${{ github.workspace }}/scripts/fetch-artifact.sh ${{ matrix.images.artifact }} ${{ matrix.images.version }} ${{ matrix.images.classifier }} ${{ matrix.images.group }} ${{ matrix.images.path }}
working-directory: ${{ github.workspace }}

- name: Build Docker image
uses: docker/build-push-action@a254f8ca60a858f3136a2f1f23a60969f2c402dd # 6.4.0
with:
context: .
tags: ${{ matrix.images.name }}:test
push: false
load: true
file: ${{ github.workspace }}/${{ matrix.images.path }}/Dockerfile

- name: Run Docker image
run: docker run -d -p 8080:8080 ${{ matrix.images.name }}:test

- name: Wait for container
run: sleep 30s
- name: Bake Docker images
uses: docker/bake-action@eac74531aa56a9266bfedfe5edb6b851ce2cca2b # v5.4.0

- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]

- name: Save Docker image
run: docker save ${{ matrix.images.name }}:test -o /tmp/${{ matrix.images.name }}.tar

- name: Upload image as a tar for next job
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # 4.3.4
with:
name: ${{ matrix.images.name }}-${{ github.run_number }}
path: /tmp/${{ matrix.images.name }}.tar

compose:
name: docker-compose
needs: build-run-test
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287 # 3.4.0

- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
with:
path: /tmp
pattern: "*-${{ github.run_number }}"
merge-multiple: true

- name: Load Docker images
run: |
ls -1 /tmp/*.tar | xargs --no-run-if-empty -L 1 docker load -i
docker image ls -a
- name: Show all images
run: docker images

- name: Verify docker-compose
uses: Alfresco/alfresco-build-tools/.github/actions/dbp-charts/[email protected]
Expand Down
175 changes: 175 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
group "default" {
targets = ["content_service", "enterprise-search"]
}

group "content_service" {
targets = ["repository"]
}

group "enterprise-search" {
targets = ["search_liveindexing"]
}

variable "LABEL_VENDOR" {
default = "Hyland Software, Inc."
}

variable "LABEL_AUTHOR" {
default = "Alfresco OPS-Readiness"
}

variable "LABEL_SOURCE" {
default = "https://github.com/Alfresco/alfresco-dockerfiles"
}

variable "CODE_REF" {
default = "local"
}

variable "PRODUCT_LINE" {
default = "Alfresco"
}

variable "CREATED" {
default = formatdate("YYYY'-'MM'-'DD'T'hh':'mm':'ss'Z'", timestamp())
}

variable "REVISION" {
default = "$GITHUB_RUN_NUMBER"
}

variable "DISTRIB_NAME" {
default = "rockylinux"
}

variable "DISTRIB_MAJOR" {
default = "9"
}

variable "JDIST" {
default = "jre"
}

variable "IMAGE_BASE_LOCATION" {
default = "docker.io/rockylinux:9"
}

variable "JAVA_MAJOR" {
default = "17"
}

variable "LIVEINDEXING" {
default = "metadata"
}

target "java_base" {
dockerfile = "./java/Dockerfile"
args = {
DISTRIB_NAME = "${DISTRIB_NAME}"
DISTRIB_MAJOR = "${DISTRIB_MAJOR}"
JDIST = "${JDIST}"
IMAGE_BASE_LOCATION = "${IMAGE_BASE_LOCATION}"
JAVA_MAJOR = "${JAVA_MAJOR}"
LABEL_NAME = "${PRODUCT_LINE} Java"
LABEL_VENDOR = "${LABEL_VENDOR}"
CREATED = "${CREATED}"
REVISION = "${REVISION}"
}
labels = {
"org.label-schema.schema-version" = "1.0"
"org.label-schema.name" = "${PRODUCT_LINE} Java"
"org.label-schema.vendor" = "${LABEL_VENDOR}"
"org.label-schema.build-date" = "${CREATED}"
"org.label-schema.url" = "$LABEL_SOURCE"
"org.label-schema.vcs-url" = "$LABEL_SOURCE"
"org.label-schema.vcs-ref" = "$CODE_REF"
"org.opencontainers.image.title" = "${PRODUCT_LINE} Java"
"org.opencontainers.image.description" = "A base image shipping OpenJDK JRE ${JAVA_MAJOR} for Alfresco Products"
"org.opencontainers.image.vendor" = "${LABEL_VENDOR}"
"org.opencontainers.image.created" = "${CREATED}"
"org.opencontainers.image.revision" = "${REVISION}"
"org.opencontainers.image.url" = "$LABEL_SOURCE"
"org.opencontainers.image.source" = "$LABEL_SOURCE"
"org.opencontainers.image.authors" = "${LABEL_AUTHOR}"
}
tags = ["alfresco-base-java:${JDIST}${JAVA_MAJOR}-${DISTRIB_NAME}${DISTRIB_MAJOR}"]
output = ["type=cacheonly"]
}

variable "TOMCAT_MAJOR" {
default = "10"
}

variable "TOMCAT_VERSION" {
default = "10.1.26"
}

variable "TOMCAT_SHA512" {
default = "0a62e55c1ff9f8f04d7aff938764eac46c289eda888abf43de74a82ceb7d879e94a36ea3e5e46186bc231f07871fcc4c58f11e026f51d4487a473badb21e9355"
}

variable "TCNATIVE_VERSION" {
default = "1.3.0"
}

variable "TCNATIVE_SHA512" {
default = "5a6c7337280774525c97e36e24d7d278ba15edd63c66cec1b3e5ecdc472f8d0535e31eac83cf0bdc68810eb779e2a118d6b4f6238b509f69a71d037c905fa433"
}

target "tomcat_base" {
dockerfile = "./tomcat/Dockerfile"
inherits = ["java_base"]
contexts = {
java_base = "target:java_base"
}
args = {
TOMCAT_MAJOR = "${TOMCAT_MAJOR}"
TOMCAT_VERSION = "${TOMCAT_VERSION}"
TOMCAT_SHA512 = "${TOMCAT_SHA512}"
TCNATIVE_VERSION = "${TCNATIVE_VERSION}"
TCNATIVE_SHA512 = "${TCNATIVE_SHA512}"
LABEL_NAME = "${PRODUCT_LINE} Tomcat"
}
labels = {
"org.opencontainers.image.title" = "${PRODUCT_LINE} Tomcat"
"org.opencontainers.image.description" = "A base image shipping Tomcat for Alfresco Products"
}
tags = ["alfresco-base-tomcat:tomcat${TOMCAT_MAJOR}-${JDIST}${JAVA_MAJOR}-${DISTRIB_NAME}${DISTRIB_MAJOR}"]
output = ["type=cacheonly"]
}

target "repository" {
context = "./repository"
dockerfile = "Dockerfile"
inherits = ["tomcat_base"]
contexts = {
tomcat_base = "target:tomcat_base"
}
labels = {
"org.opencontainers.image.title" = "${PRODUCT_LINE} Content Repository"
"org.opencontainers.image.description" = "Alfresco Content Services Repository"
}
tags = ["alfresco-content-repository:latest"]
output = ["type=docker"]
}

target "search_liveindexing" {
matrix = {
liveindexing = ["metadata", "path"]
}
name = "search_liveindexing-${liveindexing}"
args = {
LIVEINDEXING = "${liveindexing}"
}
dockerfile = "./search/enterprise/common/Dockerfile"
inherits = ["java_base"]
contexts = {
java_base = "target:java_base"
}
labels = {
"org.opencontainers.image.title" = "${PRODUCT_LINE} Enterprise Search - ${liveindexing}"
"org.opencontainers.image.description" = "${PRODUCT_LINE} Enterprise Search - ${liveindexing} live indexing"
}
tags = ["alfresco-elasticsearch-live-indexing-${liveindexing}:latest"]
output = ["type=docker"]
}
6 changes: 3 additions & 3 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "2"
services:
alfresco:
image: quay.io/alfresco/alfresco-content-repository:23.2.1
image: quay.io/alfresco/alfresco-content-repository:23.2.2
mem_limit: 1900m
environment:
JAVA_TOOL_OPTIONS: >-
Expand Down Expand Up @@ -182,12 +182,12 @@ services:
ports:
- "9090:9090"
live-indexing-metadata:
image: alfresco-enterprise-search-metadata:test
image: alfresco-elasticsearch-live-indexing-metadata:latest
environment:
SPRING_ELASTICSEARCH_REST_URIS: http://elastic:9200
SPRING_ACTIVEMQ_BROKERURL: nio://activemq:61616
live-indexing-path:
image: alfresco-enterprise-search-path:test
image: alfresco-elasticsearch-live-indexing-path:latest
environment:
SPRING_ELASTICSEARCH_REST_URIS: http://elasticsearch:9200
SPRING_ACTIVEMQ_BROKERURL: nio://activemq:61616
Expand Down
29 changes: 29 additions & 0 deletions java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Alfresco Base Java Image
ARG DISTRIB_NAME
ARG DISTRIB_MAJOR
ARG IMAGE_BASE_LOCATION=docker.io/rockylinux:9

FROM ${IMAGE_BASE_LOCATION} AS rhlike

ARG JDIST
ARG JAVA_MAJOR

ENV JAVA_HOME /etc/alternatives/jre
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

RUN \
yum update --security -y && \
yum install -y langpacks-en java-${JAVA_MAJOR}-openjdk-headless && \
yum clean all && rm -rf /var/cache/yum

FROM rhlike AS rockylinux8
FROM rhlike AS rockylinux9
FROM rhlike AS rhel8

FROM ${DISTRIB_NAME}${DISTRIB_MAJOR}
ARG DISTRIB_NAME
ARG DISTRIB_MAJOR
ARG JAVA_MAJOR

RUN $JAVA_HOME/bin/java -version
21 changes: 12 additions & 9 deletions repository/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM quay.io/alfresco/alfresco-base-tomcat:tomcat10-jre17-rockylinux9 as BUILD
FROM tomcat_base AS repo_build

USER root
RUN yum install -y unzip

ADD alfresco-content-services-distribution-23.2.1.zip /tmp/
ADD alfresco-content-services-distribution-*.zip /tmp/

RUN unzip /tmp/alfresco-content-services-distribution-23.2.1.zip -d /tmp/distribution
RUN unzip /tmp/alfresco-content-services-distribution-*.zip -d /tmp/distribution

RUN mkdir -p /usr/local/tomcat/shared/classes/alfresco/extension/keystore/

RUN cp /tmp/distribution/web-server/webapps/alfresco.war /usr/local/tomcat/webapps/
RUN unzip /tmp/distribution/web-server/webapps/alfresco.war -d /usr/local/tomcat/webapps/alfresco/
RUN cp -ra /tmp/distribution/web-server/conf/* /usr/local/tomcat/conf/ && rm -f /usr/local/tomcat/conf/Catalina/localhost/share.xml
RUN cp -ra /tmp/distribution/web-server/lib/* /usr/local/tomcat/lib/
RUN cp -ra /tmp/distribution/web-server/shared/* /usr/local/tomcat/shared/
Expand All @@ -17,13 +18,15 @@ RUN cp -ra /tmp/distribution/keystore/metadata-keystore/keystore* /usr/local/tom
RUN sed -i 's|shared.loader=|shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar|' /usr/local/tomcat/conf/catalina.properties
RUN sed -i 's|../modules/platform|modules/platform|' /usr/local/tomcat/conf/Catalina/localhost/alfresco.xml

FROM quay.io/alfresco/alfresco-base-tomcat:tomcat10-jre17-rockylinux9
FROM tomcat_base

RUN mkdir -p /usr/local/tomcat/modules/platform /usr/local/tomcat/modules/share

COPY --from=BUILD /usr/local/tomcat/conf /usr/local/tomcat/conf
COPY --from=BUILD /usr/local/tomcat/lib /usr/local/tomcat/lib
COPY --from=BUILD /usr/local/tomcat/shared /usr/local/tomcat/shared
COPY --from=BUILD /usr/local/tomcat/webapps /usr/local/tomcat/webapps
COPY --from=repo_build /usr/local/tomcat/conf /usr/local/tomcat/conf
COPY --from=repo_build /usr/local/tomcat/lib /usr/local/tomcat/lib
COPY --from=repo_build /usr/local/tomcat/shared /usr/local/tomcat/shared
COPY --from=repo_build /usr/local/tomcat/webapps /usr/local/tomcat/webapps

USER tomcat

CMD ["catalina.sh", "run"]
13 changes: 13 additions & 0 deletions repository/artifacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"artifacts": {
"acs23": [
{
"name": "alfresco-content-services-distribution",
"version": "23.2.2",
"path": "repository",
"classifier": ".zip",
"group": "org.alfresco"
}
]
}
}
Loading