Skip to content

Commit

Permalink
Merge branch 'release/v0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dasscheman committed Jul 2, 2024
2 parents 7a5b271 + e5d78f2 commit 2d0fc58
Show file tree
Hide file tree
Showing 27 changed files with 707 additions and 132 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/docker-image-Frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Create and publish Frontend Docker image

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
branches: [ "master", "develop"]
pull_request:
branches: [ "master", "develop", "feature/**"]
types: ["opened", "synchronize"]

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-Frontend
TAG_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-frontend-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
file: ./openshift/frontend.dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
# * name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true
#
96 changes: 65 additions & 31 deletions .github/workflows/docker-image-Laravel.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,71 @@
name: Docker Image Laravel
env:
# 🖊️ EDIT to change the image registry settings.
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
IMAGE_REGISTRY: ghcr.io/utrechtuniversity
IMAGE_REGISTRY_USER: ${{ github.actor }}
IMAGE_REGISTRY_PASSWORD: ${{ github.token }}
COMPOSER_TOKEN: ${{ secrets.ACCESS_TOKEN_GITHUB }}
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{secrets.ACCESS_TOKEN_GITHUB}}"} }' # [tl! **]
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN_GITHUB }}
name: Create and publish Backend Docker image

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
branches: [ "master", "develop", "feature/da_add_la_basepackage"]
branches: [ "master", "develop"]
pull_request:
branches: [ "master" ]
branches: [ "master", "develop", "feature/**"]
types: ["opened", "synchronize"]

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-backend
TAG_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build:
build-and-push-backend-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- uses: actions/checkout@v4
- name: Build from Dockerfile
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: fsw-openshift
tags: latest develop
dockerfiles: |
./openshift/openshift.dockerfile
- name: Push to registry
id: push-image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_REGISTRY_USER }}
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Install dependencies
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{secrets.COMPOSER_AUTH}}"} }' # [tl! **]
run: composer update && composer install --prefer-dist --no-suggest --no-progress
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
file: ./openshift/openshift.dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
# * name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true
#
3 changes: 2 additions & 1 deletion .github/workflows/docker-image-Nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ env:
IMAGE_REGISTRY: ghcr.io/utrechtuniversity
IMAGE_REGISTRY_USER: ${{ github.actor }}
IMAGE_REGISTRY_PASSWORD: ${{ github.token }}
TAG_NAME: ${{ github.repository }}
on:
push:
branches: [ "master", "develop", "feature/da_opschonen" ]
branches: [ "master", "develop"]
pull_request:
branches: [ "master" ]
jobs:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ https://www.redhat.com/sysadmin/codeready-containers
Soms wil hij niet starten, dan moet je de vm verwijderen en opnieuw starten:
`crc cleanup`

https://console-openshift-console.apps-crc.testing/

oc login -u developer -p developer https://api.crc.testing:6443
### Local development:
Add the following to your /etc/hosts file:

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ services:
build:
dockerfile: docker/frontend.dockerfile
volumes:
- ./:/var/www/public
working_dir: /var/www/public
- ./:/var/www
working_dir: /var/www
ports:
- "7050:7050"
networks:
Expand Down
16 changes: 4 additions & 12 deletions docker/backend.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ COPY composer.lock composer.json /var/www/
WORKDIR /var/www

# upgrades!
RUN apt-get update -y
RUN apt-get update
RUN apt-get -y dist-upgrade
RUN apt-get -qq install -y zip

RUN apt-get -qq install -y sudo nano
RUN apt-get -qq install -y mariadb-client

RUN apt-get -qq install -y libonig-dev
RUN apt-get -qq install -y ca-certificates curl gnupg
RUN apt-get -qq install -y ca-certificates curl gnupg git

# required for sending mail.
RUN apt-get -qq install -y sendmail
Expand Down Expand Up @@ -45,18 +45,10 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY .. /var/www

# install & run composer
#COPY ./docker/auth.json /root/.composer/auth.json
RUN echo "COMPOSER_TOKEN"
RUN echo "COMPOSER_TOKEN"
RUN echo $(COMPOSER_TOKEN)
RUN echo "GITHUB_TOKEN"
RUN echo $(GITHUB_TOKEN)
RUN echo "COMPOSER_AUTH"
RUN echo $(COMPOSER_AUTH) > /root/.composer/auth.json

COPY ./docker/auth.json /root/.composer/auth.json
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
# run composer

# run composer
RUN composer install

# install self signed certifcates to thrust other local dev environments
Expand Down
4 changes: 0 additions & 4 deletions docker/frontend-entrypoint.sh

This file was deleted.

21 changes: 11 additions & 10 deletions docker/frontend.dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
FROM node:20-alpine
# set workdir
RUN mkdir -p /var/www/
RUN mkdir /var/www && chown node:node /var/www
WORKDIR /var/www

# copy webapp files
COPY .. /var/www
RUN npm install
RUN npm run build
RUN apk add --no-cache git

COPY --chown=node:node package.json package-lock.json* vite.config.js ./

# entrypoint
COPY ./docker/frontend-entrypoint.sh /entrypoint.sh
RUN chmod ugo+x /entrypoint.sh
RUN dos2unix /entrypoint.sh
#Naar het voorbeeld van:
#https://github.com/UtrechtUniversity/containerplatform-docs Apache rootless openshift
RUN chgrp -R 0 /var/www && \
chmod -R g=u /var/www

ENTRYPOINT /entrypoint.sh
RUN npm install
EXPOSE 7050
CMD "npm" "run" "dev"
11 changes: 11 additions & 0 deletions openshift/config/05_sample-app-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: Secret
metadata:
name: sample-app-secret
type: Opaque
data:
# Use the following command to generate a random password:
# echo -n 'ChangeThisSuperSecretPassword' | base64
oidc-client-id: <oidc-client-id>
oidc-client-secret: <oidc-client-secret>
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ data:
database-type: mysql
database-host: mariadb-sample
database-port-number: '3306'
database-name: sample-database
database-name: sample-database
oidc-provider-url: https://login.acc.uu.nl/nidp/oauth/nam
oidc-slo-link: https://login.acc.uu.nl/nidp/app/logout
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: sample-app
image: ghcr.io/utrechtuniversity/fsw-openshift:latest
image: ghcr.io/utrechtuniversity/fsw-openshift:develop
ports:
- containerPort: 9000
env:
Expand All @@ -41,11 +41,31 @@ spec:
configMapKeyRef:
name: sample-config
key: database-name
- name: OIDC_PROVIDER_URL
valueFrom:
configMapKeyRef:
name: sample-config
key: oidc-provider-url
- name: OIDC_SLO_LINK
valueFrom:
configMapKeyRef:
name: sample-config
key: oidc-slo-link
- name: LARAVEL_DATABASE_USER
valueFrom:
configMapKeyRef:
name: mariadb-config
key: mariadb-user
- name: OIDC_CLIENT_ID
valueFrom:
secretKeyRef:
name: sample-app-secret
key: oidc-client-id
- name: OIDC_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: sample-app-secret
key: oidc-client-secret
- name: LARAVEL_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions openshift/config/09_sample-front-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: sample-frontend-config
data:
vite-api-url: app.openshift.fss.uu.nl
vite-port: '7050'
33 changes: 33 additions & 0 deletions openshift/config/10_sample-front.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: fsw-sample-front
labels:
app: fsw-sample-app
app.kubernetes.io/part-of: fsw-sample-app
spec:
replicas: 1
selector:
matchLabels:
app: sample-front
template:
metadata:
labels:
app: sample-front
spec:
containers:
- name: sample-front
image: ghcr.io/utrechtuniversity/fsw-openshift-frontend:develop
ports:
- containerPort: 7050
env:
- name: VITE_API_URL
valueFrom:
configMapKeyRef:
name: sample-frontend-config
key: vite-api-url
- name: VITE_PORT
valueFrom:
configMapKeyRef:
name: sample-frontend-config
key: vite-port
13 changes: 13 additions & 0 deletions openshift/config/11_sample-front-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: sample-front
labels:
app: fsw-sample-app
app.kubernetes.io/part-of: fsw-sample-app
spec:
ports:
- port: 7050
targetPort: 7050
selector:
app: sample-front
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2d0fc58

Please sign in to comment.