Skip to content

Commit

Permalink
Use nginx on openshift.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasscheman committed Jun 21, 2024
1 parent 37633d2 commit d4972e6
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 19 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker-image-Laravel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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 }}


on:
push:
branches: [ "master" "develop" ]
pull_request:
branches: [ "master" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: Laravel
tags: ${{ env.IMAGE_TAGS }}

# If you don't have a Dockerfile/Containerfile, refer to https://github.com/redhat-actions/buildah-build#scratch-build-inputs
# Or, perform a source-to-image build using https://github.com/redhat-actions/s2i-build
# Otherwise, point this to your Dockerfile/Containerfile relative to the repository root.
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 }}
44 changes: 44 additions & 0 deletions .github/workflows/docker-image-Nginx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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 }}


on:
push:
branches: [ "master" "develop" ]
pull_request:
branches: [ "master" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: Nginx
tags: ${{ env.IMAGE_TAGS }}

# If you don't have a Dockerfile/Containerfile, refer to https://github.com/redhat-actions/buildah-build#scratch-build-inputs
# Or, perform a source-to-image build using https://github.com/redhat-actions/s2i-build
# Otherwise, point this to your Dockerfile/Containerfile relative to the repository root.
dockerfiles: |
./openshift/nginx.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 }}
18 changes: 0 additions & 18 deletions .github/workflows/docker-image.yml

This file was deleted.

8 changes: 8 additions & 0 deletions openshift/nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM nginxinc/nginx-unprivileged:stable-alpine

ADD ./openshift/vhost.conf /etc/nginx/conf.d/default.conf


# Expose port 8443 and start php-fpm server
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion openshift/openshift-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ composer install --no-dev --no-scripts

npm run build

php artisan serve --host=0.0.0.0 --port=8080
#php artisan serve --host=0.0.0.0 --port=8080
php-fpm
19 changes: 19 additions & 0 deletions openshift/sample/7_nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: ghcr.io/utrechtuniversity/openshift-nginx:latest
ports:
- containerPort: 8080
20 changes: 20 additions & 0 deletions openshift/vhost.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 80;
server_name app.openshift.fss.uu.nl;
index index.php index.html;
root /var/www/public;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
try_files $uri /index.php?$args;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass backend:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

0 comments on commit d4972e6

Please sign in to comment.