Skip to content

Commit 38b6ecb

Browse files
committed
CF-4251:docker image for postgreSQL array fix
1 parent 248b380 commit 38b6ecb

File tree

3 files changed

+103
-12
lines changed

3 files changed

+103
-12
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- fix/postgresql-array-handling #branch name which is used for image building
7+
8+
jobs:
9+
build:
10+
runs-on: self-hosted
11+
permissions:
12+
contents: read
13+
packages: read
14+
15+
env:
16+
ECR_REPOSITORY: atomhopper
17+
AWS_REGION: us-east-1
18+
19+
steps:
20+
- name: checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Set Short commit SHA as image tag
24+
run: echo "IMAGE_TAG=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
25+
26+
- name: GitHub Packages login
27+
run: |
28+
echo "Logging into GitHub Container Registry..."
29+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
30+
echo "Logging into GitHub Packages Maven registry..."
31+
echo ${{ secrets.GITHUB_TOKEN }} | docker login maven.pkg.github.com -u ${{ github.actor }} --password-stdin
32+
33+
- name: AWS ECR login
34+
run: |
35+
aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
36+
- name: Build docker image
37+
run: |
38+
cd docker
39+
echo "Building Docker image with GitHub authentication..."
40+
docker build \
41+
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
42+
--build-arg GITHUB_ACTOR=${{ github.actor }} \
43+
--progress=plain \
44+
-t atomhopper:latest-alpine .
45+
echo "Tagging images for ECR..."
46+
docker tag atomhopper:latest-alpine ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
47+
docker tag atomhopper:latest-alpine ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}:latest
48+
- name: Push docker image to registry
49+
run: |
50+
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
51+
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}:latest

docker/Dockerfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ FROM tomcat:9.0.41-jdk8 as tomcat
33

44
FROM adoptopenjdk/openjdk8:alpine-slim
55

6+
# Build arguments for GitHub authentication
7+
ARG GITHUB_TOKEN
8+
ARG GITHUB_ACTOR
9+
10+
# Validate that authentication arguments are provided
11+
RUN if [ -z "$GITHUB_TOKEN" ] || [ -z "$GITHUB_ACTOR" ]; then \
12+
echo "ERROR: GITHUB_TOKEN and GITHUB_ACTOR build arguments are required for GitHub Packages authentication"; \
13+
exit 1; \
14+
fi
15+
616
LABEL maintainer="AtomHopperTeam@rackspace.com" \
717
#Atom Hopper version
8-
version="1.2.33" \
18+
version="1.2.35" \
919
description="Docker image for Atom Hopper"
1020

1121
#The database type
@@ -16,7 +26,7 @@ ENV DB_TYPE=H2 \
1626
DB_PASSWORD= \
1727
#Database Host:Port
1828
DB_HOST=h2 \
19-
AH_VERSION=1.2.33 \
29+
AH_VERSION=1.2.35 \
2030
CATALINA_HOME=/opt/tomcat \
2131
AH_HOME=/opt/atomhopper \
2232
PATH=${PATH}:${CATALINA_HOME}/bin:${AH_HOME}
@@ -28,14 +38,18 @@ WORKDIR ${AH_HOME}
2838
COPY --from=tomcat /usr/local/tomcat ${CATALINA_HOME}
2939
COPY start.sh .
3040

31-
RUN apk --no-cache add curl \
32-
&& curl -o atomhopper.war https://maven.research.rackspacecloud.com/content/repositories/releases/org/atomhopper/atomhopper/${AH_VERSION}/atomhopper-${AH_VERSION}.war \
41+
RUN apk --no-cache add curl unzip \
42+
&& echo "Downloading AtomHopper ${AH_VERSION} from GitHub Packages..." \
43+
&& curl -f -u ${GITHUB_ACTOR}:${GITHUB_TOKEN} -o atomhopper.war \
44+
"https://maven.pkg.github.com/rackerlabs/atom-hopper/org/atomhopper/atomhopper/${AH_VERSION}/atomhopper-${AH_VERSION}.war" \
45+
&& echo "Download completed, extracting configuration files..." \
3346
&& unzip atomhopper.war META-INF/application-context.xml META-INF/template-logback.xml WEB-INF/classes/META-INF/atom-server.cfg.xml -d . \
3447
&& mv META-INF/application-context.xml WEB-INF/classes/META-INF/atom-server.cfg.xml /etc/atomhopper/ \
3548
&& mv META-INF/template-logback.xml /etc/atomhopper/logback.xml \
3649
&& mv atomhopper.war ${CATALINA_HOME}/webapps/ROOT.war \
3750
&& rm -rf META-INF WEB-INF \
38-
&& chmod +x ${AH_HOME}/start.sh
51+
&& chmod +x ${AH_HOME}/start.sh \
52+
&& echo "AtomHopper ${AH_VERSION} setup completed successfully"
3953

4054
EXPOSE 8080
4155

docker/README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
1-
# docker build image and run the conatiner
2-
Your current direcotry should be pointing to ***atom-hopper/docker***.
3-
Run the following command to build an image.
4-
```
5-
$docker build -t atomhopper:latest-alpine .
1+
# docker build image and run the container
2+
3+
## Building the Docker Image
4+
5+
Your current directory should be pointing to ***atom-hopper/docker***.
6+
7+
### Prerequisites
8+
The Docker build now downloads AtomHopper from GitHub Packages, which requires authentication. You need:
9+
- A GitHub Personal Access Token with `packages:read` permission
10+
- Your GitHub username
11+
12+
### Build Command
13+
Run the following command to build an image with GitHub authentication:
14+
```bash
15+
docker build \
16+
--build-arg GITHUB_TOKEN=your_github_token \
17+
--build-arg GITHUB_ACTOR=your_github_username \
18+
-t atomhopper:latest-alpine .
619
```
7-
You can use the following command to run a container by provinding the appropriate values to the variables.
20+
21+
### Alternative: Using Environment Variables
22+
You can also set environment variables and build:
23+
```bash
24+
export GITHUB_TOKEN=your_github_token
25+
export GITHUB_ACTOR=your_github_username
26+
docker build \
27+
--build-arg GITHUB_TOKEN=$GITHUB_TOKEN \
28+
--build-arg GITHUB_ACTOR=$GITHUB_ACTOR \
29+
-t atomhopper:latest-alpine .
30+
```
31+
## Running the Container
32+
33+
You can use the following command to run a container by providing the appropriate values to the variables.
834
```
935
$docker run -d --name [Conatiner_Name] -p 8080:8080 -e DB_TYPE=[Database_Type (PostgreSQL, MySQL)] -e DB_USER=[Database_Username] -e DB_PASSWORD=[Database_Password] -e DB_HOST=[IP:PORT] atomhopper:latest-alpine
1036
```
@@ -22,7 +48,7 @@ Following environment variables are set by default
2248
JAVA_HOME "/opt/java/openjdk8/jre"
2349
CATALINA_HOME "/opt/tomcat"
2450
AH_HOME "/opt/atomhopper"
25-
AH_VERSION "1.2.33"
51+
AH_VERSION "1.2.35"
2652
```
2753
For specific databse configuration of your choice (PostgreSQL,MySQL) provide values for the variables DB_TYPE, DB_USER, DB_PASSWORD and DB_HOST
2854

0 commit comments

Comments
 (0)