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

feat: optimise build process #1012

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 6 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
proxies: '[{ "id":"dvsa-ci-proxy", "active": "true", "protocol": "http", "host": "${{vars.CI_PROXY}}", "port": "${{vars.CI_PROXYPORT}}" }]'
repositories: '[ { "id":"dvsa-github-packages", "name":"dvsa-github-packages", "url":"https://maven.pkg.github.com/dvsa/*", "releases": { "enabled": "true" }, "snapshots": { "enabled": "true" } }]'
output_file: ./settings.xml

- name: view settings.xml
run: cat ./settings.xml

Expand All @@ -60,7 +60,6 @@ jobs:

- name: Extract Docker metadata
id: meta

uses: docker/metadata-action@v5
with:
images: |
Expand Down Expand Up @@ -96,20 +95,22 @@ jobs:
if: ${{ inputs.push }}
run: |
aws ecr batch-delete-image --repository-name vol-qa/vft --image-ids imageTag=latest

- name: Build ${{ inputs.push && 'and push ' || '' }}Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
context: .
file: infra/docker/batch/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


- name: Remove settings.xml
run: rm -f ./settings.xml

- name: Setup Notation CLI
if: ${{ inputs.push }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/e2etest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ jobs:
--timeout "attemptDurationSeconds=$(( ${{ inputs.batch_timeout_minutes }} * 60 ))" \
--container-overrides '{
"command": [
"/bin/sh",
"-c",
"./run.sh"
"java",
"-cp",
"app.jar"
"AppJarRunner"
],
"environment": [
{
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*.tar.gz
*.rar

# Ignore Maven settings file
settings.xml

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

Expand Down
47 changes: 31 additions & 16 deletions infra/docker/batch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
FROM maven:3.9.6-amazoncorretto-11 as maven
FROM maven:3.9.6-amazoncorretto-11 AS builder
WORKDIR /build

ENV platform="LINUX"
ENV gridURL="https://selenium-hub.olcs.dev-dvsacloud.uk/"
COPY pom.xml .
COPY settings.xml /root/.m2/settings.xml
COPY src ./src
RUN mvn clean package -DskipTests

FROM amazoncorretto:11

ENV proxyHost=$proxyHost
ENV proxyPort=$proxyPort
# hadolint ignore=DL3044
ENV JAVA_HOME=/usr/lib/jvm/java-11-amazon-corretto \
MAVEN_HOME=/usr/share/maven \
PATH=${JAVA_HOME}/bin:/usr/share/maven/bin:${PATH}

WORKDIR /app

RUN yum update -y && \
yum install -y zip-3.* unzip-6.* && \
yum install -y \
zip-3.* \
unzip-6.* \
curl-7.* \
python3-3.* && \
yum clean all && \
rm -rf /var/cache/yum
rm -rf /var/cache/yum && \
python3 -m pip install --no-cache-dir awscli==1.27.165

# Install latest version of the aws cli
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update && \
rm -f awscliv2.zip
COPY --from=builder /usr/share/maven /usr/share/maven

COPY . .
RUN mkdir -p /root/.m2
COPY settings.xml /root/.m2/settings.xml
COPY --from=builder /root/.m2/repository /root/.m2/repository

COPY ./settings.xml /root/.m2/settings.xml
RUN ls -la /usr/share/maven/bin/mvn && \
chmod +x /usr/share/maven/bin/mvn

COPY pom.xml ./pom.xml
COPY src ./src

RUN chmod +x ./run.sh
COPY --from=builder /build/target/*.jar ./app.jar

CMD ["/bin/sh", "-c", "./run.sh"]
# Remove settings.xml after use
RUN rm -f /root/.m2/settings.xml

ENTRYPOINT ["java", "-jar", "app.jar"]
110 changes: 81 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<axe-scanner-version>2.11.0</axe-scanner-version>


<allure-cucumber7-jvm.version>2.20.1</allure-cucumber7-jvm.version>
<allure-cucumber7-jvm.version>2.29.1</allure-cucumber7-jvm.version>
<allure-report.version>2.25.0</allure-report.version>

<slf4j.version>2.22.0</slf4j.version>
Expand All @@ -28,9 +28,10 @@
<hamcrest-version>1.3</hamcrest-version>

<aspectj.version>1.9.21</aspectj.version>
<build.helper.plugin.version>3.2.0</build.helper.plugin.version>
<build.helper.plugin.version>3.9.9</build.helper.plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
<apache-commons.version>1.10.0</apache-commons.version>
<jsoup.version>1.17.1</jsoup.version>
<gson.version>2.10.1</gson.version>
Expand All @@ -40,24 +41,24 @@
<jvmMemory>14400</jvmMemory>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>7.15.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- <dependencyManagement>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>org.junit</groupId>-->
<!-- <artifactId>junit-bom</artifactId>-->
<!-- <version>5.10.1</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.cucumber</groupId>-->
<!-- <artifactId>cucumber-bom</artifactId>-->
<!-- <version>7.15.0</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </dependencyManagement>-->

<repositories>
<repository>
Expand All @@ -81,16 +82,20 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.20.1</version>
<scope>test</scope>

</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.20.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.11.3</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -151,7 +156,14 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.20.1</version>
<scope>test</scope>

</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>4.0.0-beta-1</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
Expand Down Expand Up @@ -254,21 +266,61 @@
</configuration>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.12.0</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>AppJarRunner</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<reportingOutputDirectory>${project.basedir}/target/site/allure-report
</reportingOutputDirectory>
<reportVersion>${allure-report.version}</reportVersion>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>AppJarRunner</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>generate-test-report</id>
<phase>verify</phase>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Loading
Loading