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-2800 Add share component Dockerfile #47

Merged
merged 12 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ prepare_connectors: scripts/fetch-artifacts.sh setenv
@echo "Fetching all artifacts for Connectors targets"
@./scripts/fetch-artifacts.sh connector

prepare_share: scripts/fetch-artifacts.sh setenv
@echo "Fetching all artifacts for Share targets"
@./scripts/fetch-artifacts.sh share

prepare_all: scripts/fetch-artifacts.sh setenv
@echo "Fetching all artifacts"
@./scripts/fetch-artifacts.sh
Expand All @@ -77,6 +81,10 @@ connectors: prepare_connectors
@echo "Building Connectors images"
docker buildx bake ${DOCKER_BAKE_ARGS} connectors

share: prepare_share
@echo "Building Share images"
docker buildx bake ${DOCKER_BAKE_ARGS} share

all: docker-bake.hcl prepare_all
@echo "Building all images"
docker buildx bake ${DOCKER_BAKE_ARGS}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Using this tool to build Alfresco images requires:
require authentication
* Some Unix tools: `jq`, `wget`, `make`

Configuring the authentication to Alfresco NExus server must be dopne using the
Configuring the authentication to Alfresco Nexus server must be done using the
wget rc file `~/.wgetrc` or `~/.netrc`:

```sh
Expand Down
32 changes: 31 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ group "default" {
}

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

group "enterprise-search" {
Expand Down Expand Up @@ -546,3 +546,33 @@ target "connector_ms365" {
output = ["type=docker"]
platforms = split(",", "${TARGETARCH}")
}

variable "ALFRESCO_SHARE_USER_NAME" {
default = "share"
}

variable "ALFRESCO_SHARE_USER_ID" {
default = "33010"
}

target "share" {
context = "./share"
dockerfile = "Dockerfile"
inherits = ["tomcat_base"]
contexts = {
tomcat_base = "target:tomcat_base"
}
args = {
ALFRESCO_SHARE_GROUP_NAME = "${ALFRESCO_GROUP_NAME}"
ALFRESCO_SHARE_GROUP_ID = "${ALFRESCO_GROUP_ID}"
ALFRESCO_SHARE_USER_NAME = "${ALFRESCO_SHARE_USER_NAME}"
ALFRESCO_SHARE_USER_ID = "${ALFRESCO_SHARE_USER_ID}"
}
labels = {
"org.opencontainers.image.title" = "${PRODUCT_LINE} Share"
"org.opencontainers.image.description" = "Alfresco Share"
}
tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-share:${TAG}"]
output = ["type=docker"]
platforms = split(",", "${TARGETARCH}")
}
2 changes: 1 addition & 1 deletion repository/amps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ way to build well structured AMPs.
> SDK](https://docs.alfresco.com/content-services/latest/develop/oop-sdk/) to
> build Docker images with your extensions.

By default the `scripts/fetch-amps.sh` script will fetch the following AMPs from the Alfresco Nexus repository:
By default the `scripts/fetch-artifacts.sh` script will fetch the following AMPs from the Alfresco Nexus repository:

* alfresco-share-services
* alfresco-aos-module
Expand Down
53 changes: 53 additions & 0 deletions share/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG DISTRIB_NAME
ARG DISTRIB_MAJOR
FROM tomcat_base as share_build

USER root
EXPOSE 8000

RUN mkdir -p ${CATALINA_HOME}/shared/classes/alfresco/web-extension \
${CATALINA_HOME}/conf/Catalina/localhost

COPY entrypoint.sh ${CATALINA_HOME}/shared/classes/alfresco

ADD amps /tmp/amps
ADD distribution /tmp/
ENV DISTDIR="/tmp/distribution"

RUN yum install -y unzip
RUN unzip /tmp/*.zip -d ${DISTDIR}
RUN unzip ${DISTDIR}/alfresco*/web-server/webapps/share.war -d ${CATALINA_HOME}/webapps/share/
RUN cp -r ${DISTDIR}/alfresco*/amps/ /tmp/amps/
RUN cp ${DISTDIR}/alfresco*/web-extension-samples/custom-slingshot-application-context.xml.sample ${CATALINA_HOME}/shared/classes/alfresco/web-extension
RUN cp ${DISTDIR}/alfresco*/web-extension-samples/smartfolders-amp-actions-config.xml ${CATALINA_HOME}/shared/classes/alfresco/web-extension
RUN cp /tmp/share-config-custom.xml ${CATALINA_HOME}/shared/classes/alfresco/web-extension
RUN cp ${DISTDIR}/alfresco*/web-server/conf/Catalina/localhost/share.xml ${CATALINA_HOME}/conf/Catalina/localhost
RUN sed -i 's|../modules/share|modules/share|' ${CATALINA_HOME}/conf/Catalina/localhost/share.xml
RUN sed -i "s/shared.loader=/shared.loader=\${catalina.base}\/shared\/classes/" ${CATALINA_HOME}/conf/catalina.properties
RUN chmod +x ${CATALINA_HOME}/shared/classes/alfresco/entrypoint.sh

RUN java -jar ${DISTDIR}/alfresco*/bin/alfresco-mmt.jar install \
/tmp/amps/ ${CATALINA_HOME}/webapps/share -directory -nobackup -force

FROM tomcat_base AS share-rhlike
ARG ALFRESCO_SHARE_USER_ID
ARG ALFRESCO_SHARE_GROUP_ID
ARG ALFRESCO_SHARE_GROUP_NAME
ARG ALFRESCO_SHARE_USER_NAME

COPY --chown=${ALFRESCO_SHARE_USER_ID}:${ALFRESCO_SHARE_GROUP_ID} --from=share_build ${CATALINA_HOME} ${CATALINA_HOME}

USER root
RUN groupadd -g ${ALFRESCO_SHARE_GROUP_ID} ${ALFRESCO_SHARE_GROUP_NAME} && \
useradd -u ${ALFRESCO_SHARE_USER_ID} -g ${ALFRESCO_SHARE_GROUP_NAME} ${ALFRESCO_SHARE_USER_NAME} -G tomcat && \
mkdir -m 750 -p ${CATALINA_HOME}/modules/share && \
chgrp -R ${ALFRESCO_SHARE_GROUP_ID} ${CATALINA_HOME}/modules && \
yum install -y xmlstarlet && \
yum clean all && rm -rf /var/cache/yum

FROM share-rhlike AS share-rockylinux9

FROM share-${DISTRIB_NAME}${DISTRIB_MAJOR}
USER ${ALFRESCO_SHARE_USER_NAME}

ENTRYPOINT ["/usr/local/tomcat/shared/classes/alfresco/entrypoint.sh"]
62 changes: 62 additions & 0 deletions share/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Alfresco share image

## Description

This Docker file is used to build an Alfresco share image.

## Building the image

Make sure all required artifacts are present in the build context `share/`.
You can put them manually in the `share/` folder (for example if that's a
custom module of yours), or use the script `./scripts/fetch-artifacts.sh` to
download them from Alfresco's Nexus.

Then, you can build the image from the root of this git repository with the
following command:

```bash
docker buildx bake share
```

## Running the image

### Alfresco share configuration

All preperties you would normally add in the alfresco-global.properties file can
be added in the `JAVA_OPTS` environment variable to the container.

For example, to set the database URL, you can use the following environment
variable:

```bash
docker run -e JAVA_OPTS="-Dalfresco.host=localhost" \
alfresco-share:mytag
```

Example set of variables for docker-compose file:

```yaml

alfresco-connector-ms365:
image: localhost/alfresco-share:YOUR-TAG
environment:
JAVA_OPTS: ""
REPO_HOST: alfresco
REPO_PORT: 8080
CSRF_FILTER_REFERER:
CSRF_FILTER_ORIGIN:
USE_SSL: false

```

- `JAVA_OPTS` - A set of properties that are picked up by the JVM inside the container
- `REPO_HOST` - Share needs to know how to register itself with Alfresco. The default value is `localhost`
- `REPO_PORT` - Share needs to know how to register itself with Alfresco. The default value is `8080`
- `CSRF_FILTER_REFERER` - CSRF Referrer
- `CSRF_FILTER_ORIGIN` - CSRF Origin
- `USE_SSL` - Enables ssl use if set to `true`. The default value is `false`


> If the image is meant to be used with the Alfresco Content Services Helm
> chart, you can use other [higher level means of
> configuration](https://github.com/Alfresco/alfresco-helm-charts/blob/main/charts/alfresco-share/README.md).
24 changes: 24 additions & 0 deletions share/amps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Alfresco share AMPs

Place here your Alfresco module Packages (AMPs) to be installed in the Alfresco
share.

AMP packages should have the `.amp` extension and stick to the Alfresco module
packaging format as described in the [Alfresco
documentation](https://docs.alfresco.com/content-services/latest/develop/extension-packaging/#alfresco-module-package-amp).

The [in-process Alfresco
SDK](https://docs.alfresco.com/content-services/latest/develop/sdk/) provides a
way to build well structured AMPs.

> Note that AMPs are not the recommanded way to extend Alfresco. You should
> prefer using the Alfresco SDK to build your extensions as JARs even better,
> use the [out-of-process Alfresco
> SDK](https://docs.alfresco.com/content-services/latest/develop/oop-sdk/) to
> build Docker images with your extensions.

By default the `scripts/fetch-artifacts.sh` script will fetch the following AMPs from the Alfresco Nexus repository:

* alfresco-googledrive-share

You can replace those, remove them to keep only the ones you need or add more.
22 changes: 22 additions & 0 deletions share/artifacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"artifacts": {
"acs23": [
{
"name": "alfresco-content-services-share-distribution",
"version": "23.2.2",
"path": "share/distribution",
"classifier": ".zip",
"group": "org.alfresco",
"repository": "enterprise-releases"
},
{
"name": "alfresco-googledrive-share",
"version": "4.1.0",
"path": "share/amps",
"classifier": ".amp",
"group": "org.alfresco.integrations",
"repository": "releases"
}
]
}
}
18 changes: 18 additions & 0 deletions share/distribution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Alfresco Content Services share distribution

Place here the version of Alfresco Content Services share distribution you want to
use in your Docker image.
Distribution file must be a ZIP file with the expected structure of an Alfresco
Content Services share distribution.

```tree
amps/
bin/
web-extension-samples/
web-server/
|_webapps/
|_conf/
|_Catalina/
|_localhost/
```
Do changes to `share-config-custom.xml` according to your needs.
Loading
Loading