Skip to content

Commit

Permalink
chore: OpenShift (#61)
Browse files Browse the repository at this point in the history
* nginx config update for OpenShift
* Dockerfile update for OpenShift
* Remove old deployment method
  • Loading branch information
cbolles committed Jul 8, 2024
1 parent b189fca commit 3fd3685
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 70 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,56 +31,3 @@ jobs:

- name: Build
run: npm run build

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build & Push Docker Test Build
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: hicsail/nist-frontend:test
build-args: |
VITE_AWS_KEY=${{ secrets.VITE_AWS_KEY }}
VITE_AWS_SECRET=${{ secrets.VITE_AWS_SECRET }}
VITE_AUTH_URL=${{ secrets.VITE_AUTH_URL }}
VITE_PROJECT_ID=${{ secrets.VITE_PROJECT_ID }}
VITE_CARGO_ENDPOINT=${{ secrets.VITE_CARGO_ENDPOINT }}
VITE_S3_ENDPOINT=${{ secrets.VITE_S3_ENDPOINT }}
VITE_AUTHSERVICE_URL=${{ secrets.VITE_AUTHSERVICE_URL }}
- name: Build & Push Docker Production Build
uses: docker/build-push-action@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: hicsail/nist-frontend:production
build-args: |
VITE_AWS_KEY=${{ secrets.VITE_AWS_KEY_PROD }}
VITE_AWS_SECRET=${{ secrets.VITE_AWS_SECRET_PROD }}
VITE_AUTH_URL=${{ secrets.VITE_AUTH_URL_PROD }}
VITE_PROJECT_ID=${{ secrets.VITE_PROJECT_ID_PROD }}
VITE_CARGO_ENDPOINT=${{ secrets.VITE_CARGO_ENDPOINT_PROD }}
VITE_S3_ENDPOINT=${{ secrets.VITE_S3_ENDPOINT_PROD }}
VITE_AUTHSERVICE_URL=${{ secrets.VITE_AUTHSERVICE_URL_PROD }}
- name: Push to Staging
uses: fjogeleit/http-request-action@v1
if: github.ref == 'refs/heads/main'
with:
method: "POST"
url: ${{ secrets.PORTAINER_WEBHOOK }}
preventFailureOnNoResponse: true

- name: Push to Production
uses: fjogeleit/http-request-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
method: "POST"
url: ${{ secrets.PORTAINER_WEBHOOK_PRODUCTION }}
preventFailureOnNoResponse: true
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
FROM node:18 as build

WORKDIR /app
COPY . .
FROM node:18-alpine as builder

ARG VITE_AWS_KEY
ARG VITE_AWS_SECRET
Expand All @@ -19,15 +16,16 @@ ENV VITE_CARGO_ENDPOINT ${VITE_CARGO_ENDPOINT}
ENV VITE_S3_ENDPOINT ${VITE_S3_ENDPOINT}
ENV VITE_AUTHSERVICE_URL ${VITE_AUTHSERVICE_URL}

WORKDIR /app
COPY . .

RUN npm install
RUN npm run build

FROM nginx

COPY nginx.conf /etc/nginx/conf.d/default.conf
FROM registry.access.redhat.com/ubi7/nginx-120

COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=builder /app/dist .

COPY generate_env.sh /
ADD ./nginx.conf "${NGINX_CONF_PATH}"

CMD ["/bin/bash", "-c", "/generate_env.sh && nginx -g 'daemon off;'"]
CMD nginx -g "daemon off;"
98 changes: 91 additions & 7 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,93 @@
server {
listen 80;
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
# perl_modules /opt/app-root/etc/perl;
# perl_require Version.pm;
# perl_set $perl_version Version::installed;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';


sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /opt/app-root/etc/nginx.d/*.conf;

server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /opt/app-root/src;

# Load configuration files for the default server block.
include /opt/app-root/etc/nginx.default.d/*.conf;

location / {
try_files $uri $uri/ /index.html =404;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /opt/app-root/src;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /opt/app-root/etc/nginx.default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }

}

0 comments on commit 3fd3685

Please sign in to comment.