Skip to content

Commit

Permalink
OpenShift WIP - still partially complete, but need to commit to OS ca…
Browse files Browse the repository at this point in the history
…n pull down
  • Loading branch information
acoard committed Apr 9, 2020
1 parent e91cdf8 commit 6caf78d
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Make sure you have docker and docker-compose installed (`docker-compose --versio

# import sql - tip: use tab completion
\i BC_Timesheet_MasterData.sql
\i Risk_MasterData.sql
# \i RiskUpdate.sql - Removed as Risk_MasterData.sql has been updated with everything needed
# \i Risk_MasterData.sql - Replaced with 'latest' below.
\i Risk_MasterData_Latest.sql

# log out of container
exit
Expand Down
18 changes: 18 additions & 0 deletions openshift/templates/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM nginx:stable

RUN chmod g+rwx /var/cache/nginx /var/run /var/log/nginx
# users are not allowed to listen on priviliged ports
# RUN sed -i.bak 's/listen\(.*\)80;/listen 8081;/' /etc/nginx/conf.d/default.conf
EXPOSE 8081
# comment user directive as master process is run as user in OpenShift anyhow
# RUN sed -i.bak 's/^user/#user/' /etc/nginx/nginx.conf
COPY ./nginx.conf.template /etc/nginx/nginx.conf


WORKDIR /code

COPY ./dist .

EXPOSE 8080:8080

CMD ["nginx", "-g", "daemon off;"]
48 changes: 48 additions & 0 deletions openshift/templates/nginx/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
worker_processes auto;
error_log /var/log/nginx/error.log warn;
# pid /var/run/nginx.pid; # ORIG
pid /tmp/nginx.pid; # from OpenShift.com blog
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;

# Set custom paths for OpenShift permissions (non root)
client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp_path;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;


default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# For status of ngnix service, OpenShift is configured to call this
location /nginx_status {
# Enable Nginx stats
stub_status on;
# No need to log this request, its just noise
access_log off;
}

}
}
14 changes: 14 additions & 0 deletions openshift/templates/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# OpenShift



## Initial Setup

### Enable cross-project pulling of ImageStreams (e.g. from tools -> dev)


Run below 3 times, one for `dev`, `test`, `prod`

oc policy add-role-to-group \
system:image-puller system:serviceaccounts:aifsul-dev \
--namespace=aifsul-tools
98 changes: 98 additions & 0 deletions openshift/templates/web-build-chain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
kind: Template
apiVersion: v1
metadata:
name: timemachine-web
namespace: aifsul-tools
creationTimestamp:
objects:

# Two image-streams. "-vue" is intermediate stream used for chain build
- kind: ImageStream
apiVersion: v1
metadata:
name: "${NAME}-vue"
- kind: ImageStream
apiVersion: v1
metadata:
name: "${NAME}"

# Build-configs. First is intermediate build
- kind: BuildConfig
apiVersion: v1
metadata:
name: "${NAME}-vue"
creationTimestamp:
labels:
app: "${NAME}-vue"
spec:
runPolicy: Serial
completionDeadlineSeconds: 1800
triggers:
- type: ImageChange
source:
type: Git
git:
uri: "${GIT_SOURCE_URL}"
ref: "${GIT_REFERENCE}"
contextDir: "${CONTEXT_DIR}"
strategy:
type: Docker
output:
to:
kind: ImageStreamTag
name: "${NAME}-vue:latest"
status:
lastVersion: 0


# Create the vue-on-nginx final build
- kind: BuildConfig
apiVersion: v1
metadata:
name: ${NAME}
spec:
output:
to:
kind: ImageStreamTag
name: ${NAME}:latest
source:
type: Dockerfile
contextDir: openshift/templates/nginx
images:
- from:
kind: ImageStreamTag
name: ${NAME}-vue:latest
paths:
# Is this path modified by contextDir above? If so, remove contextDir and replace
# with dockerFilePath
- sourcePath: /dist
destinationDir: "."
strategy:
type: Docker
triggers:
- imageChange: {}
type: ImageChange


parameters:
- name: NAME
displayName: Name
description: The name assigned to all of the objects defined in this template.
required: true
value: timemachine-web
- name: GIT_SOURCE_URL
displayName: GIT Source Repo URL
description: A GIT URL to your source code.
required: true
value: https://github.com/bcgov/Project-and-time-tracker.git
- name: GIT_REFERENCE
displayName: Git Reference
description: Optional branch, tag, or commit.
required: true
value: master
- name: CONTEXT_DIR
displayName: contextDir
description: Sub directory, e.g. `api/` or `web/`
required: true
value: web/
9 changes: 5 additions & 4 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8.11.1
FROM node:12.14.1

# copy project files and folders to the web directory
COPY . /web
Expand All @@ -11,8 +11,9 @@ RUN npm install


# build app for production with minification
RUN npm run build
# RUN npm run build
CMD npm run build

EXPOSE 8080
# EXPOSE 8080

CMD [ "npm", "run", "serve" ]
# CMD [ "npm", "run", "serve" ]
9 changes: 9 additions & 0 deletions web/nginx.conf.template → web/nginx.conf.template-dev
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,14 @@ http {
location = /50x.html {
root /usr/share/nginx/html;
}

# For status of ngnix service, OpenShift is configured to call this
location /nginx_status {
# Enable Nginx stats
stub_status on;
# No need to log this request, its just noise
access_log off;
}

}
}

0 comments on commit 6caf78d

Please sign in to comment.