Skip to content

Commit

Permalink
Fix docker build lacks Github token to access Tl-Tea (#95)
Browse files Browse the repository at this point in the history
Still, the Rest API needs adjustments to handle the new inputs to MiSim.
  • Loading branch information
franksn90 committed Mar 13, 2024
1 parent 79b53cc commit 69989cb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/dockerBuildAndPush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
release:
types: [ published ] # will use tag name regardless of naming

env:
REGISTRY: ghcr.io

jobs:
build_and_publish:
runs-on: ubuntu-latest
Expand All @@ -20,14 +23,16 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
env:
GITHUB_TOKEN: ${{ secrets.READ_PACKAGES }}

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Log in to the Container registry
run: docker login --username Cambio-Project --password ${{secrets.PUBLISH_PACKAGES}} ghcr.io
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
Expand All @@ -46,11 +51,7 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
GIT_AUTH_TOKEN=${{ secrets.READ_PACKAGES }}
github-token: ${{ secrets.READ_PACKAGES }}
secret-envs: |
GITHUB_TOKEN=${{ secrets.READ_PACKAGES }}
build-args: |
EXECUTION_ENV=ci
GITHUB_PACKAGE_READ_TOKEN=${{ secrets.PUBLISH_PACKAGES }}
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
GITHUB_USER=${{ github.actor }}
13 changes: 12 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# User used in local builds to access github packages
ARG GITHUB_USER

# Token used in local builds to access github packages
# or GITHUB_TOKEN in CI
ARG GITHUB_TOKEN

# Build stage
FROM maven:3.9.6-amazoncorretto-21-debian AS build
ARG GITHUB_USER
ENV GITHUB_USER=$GITHUB_USER
ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=$GITHUB_TOKEN

# create a new working directory
WORKDIR /app
Expand All @@ -8,7 +19,7 @@ WORKDIR /app
COPY . .

# installs the maven project from the base PSPWizard
RUN mvn -B install --file pom.xml "-DskipTests=true" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skipExec=true"
RUN mvn -B install --settings settings.xml --file pom.xml -DskipTests=true -Dmaven.javadoc.skip=true -Dcheckstyle.skipExec=true -Dgithub.token=$GITHUB_TOKEN -Dgithub.name=$GITHUB_USER

# installs the restAPI Module from the PSPWizard
RUN mvn -B install --file ./restAPI/pom.xml -DskipTests=true -Dmaven.javadoc.skip=true -Dcheckstyle.skipExec=true
Expand Down
2 changes: 1 addition & 1 deletion restAPI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>cambio.simulator</groupId>
<artifactId>misim</artifactId>
<version>3.3.4-SNAPSHOT</version>
<version>3.4.0</version>
</dependency>

<dependency>
Expand Down
16 changes: 16 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<servers>
<server>
<id>github</id>
<username>${github.name}</username>
<password>${github.token}</password>
</server>
</servers>
</settings>

0 comments on commit 69989cb

Please sign in to comment.