Skip to content

Commit

Permalink
Restructure to serve static assets from express
Browse files Browse the repository at this point in the history
Also change ports and generally simplify everything :)

Signed-off-by: Tim Etchells <tetchel@gmail.com>
  • Loading branch information
tetchel committed Jun 8, 2021
1 parent c2c61b7 commit 05d65be
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 421 deletions.
1 change: 0 additions & 1 deletion .dockerignore

This file was deleted.

8 changes: 2 additions & 6 deletions .github/workflows/build-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ jobs:
dev_pid=$!
echo "dev_pid=$dev_pid" >> $GITHUB_ENV
yarn wait-on -l tcp:3000 -t 60000
yarn wait-on -l tcp:3001 -t 60000
yarn wait-on -l tcp:3003 -t 60000
yarn wait-on -l tcp:8080 -t 60000
- name: Test
shell: bash
run: |
set -eEx
curl -sSf http://localhost:3000
curl -sSf http://localhost:3001
curl -sSf http://localhost:3003
curl -sSf http://localhost:8080
- name: Stop
if: always()
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/container-build-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ jobs:
echo "View output in Logs step below"
sleep 10
yarn wait-on -l tcp:3000 -t 60000
yarn wait-on -l tcp:3003 -t 60000
yarn wait-on -l tcp:8080 -t 60000
- name: Podman inspect
run: |
Expand All @@ -54,8 +53,7 @@ jobs:
run: |
set -eEx
podman ps
curl -sSf http://localhost:3000
curl -sSf http://localhost:3003
curl -sSf http://localhost:8080
- name: Push container image
if: ${{ steps.commit_data.outputs.is_pr }} == 'false'
Expand Down
30 changes: 5 additions & 25 deletions containerize/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ FROM node:14-alpine as builder

WORKDIR /app

# https://github.com/yarnpkg/yarn/issues/2816#issuecomment-322755762
# RUN rm -v /usr/local/bin/yarn /usr/local/bin/yarnpkg && npm i -g yarn

COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile --no-cache
Expand Down Expand Up @@ -46,35 +43,18 @@ WORKDIR /app

RUN apk add curl

COPY --chown=$USER package.json yarn.lock ./
RUN yarn global add --frozen-lockfile \
# This package is used to serve the bundled, static react app
serve
# These are the external dependencies
# as specified in server webpack.config
# log4js express @kubernetes/client-node

USER $USER

ENV NODE_ENV production

ARG FRONTEND_PORT=3000
# ENV FRONTEND_PROTOCOL $PROTOCOL
ENV FRONTEND_PORT $FRONTEND_PORT

ARG PLUGIN_PORT=3001
ENV PLUGIN_PORT $PLUGIN_PORT

ARG BACKEND_PORT=3003
ENV BACKEND_PORT $BACKEND_PORT
ARG PORT=8080
ENV PORT $PORT

EXPOSE $FRONTEND_PORT
EXPOSE $PLUGIN_PORT
EXPOSE $BACKEND_PORT
EXPOSE $PORT

COPY --chown=$USER containerize/entrypoint.sh ./
COPY --chown=$USER --from=builder /app/server .
COPY --chown=$USER --from=builder /app/client ./client
COPY --chown=$USER --from=builder /app/plugin ./plugin
COPY --chown=$USER --from=builder /app/server ./server

ENTRYPOINT "./entrypoint.sh"
ENTRYPOINT [ "node", "./server.js" ]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ metadata:
spec:
displayName: "GitHub Connector"
service:
name: {{ .Values.pluginServiceName }}
name: {{ .Values.serverServiceName }}
namespace: {{ .Release.Namespace }}
port: 80
basePath: '/'
port: 443
basePath: "/console-plugin"

# also see ConsoleLink in routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ spec:
imagePullPolicy: Always
image: {{ .Values.serverImage }}:{{ .Values.serverTag }}
ports:
- name: {{ .Values.clientPortName }}
containerPort: {{ .Values.clientPort }}
- name: {{ .Values.serverPortName }}
containerPort: {{ .Values.serverPort }}
- name: {{ .Values.serverHttpPortName }}
containerPort: {{ .Values.serverHttpPort }}
- name: {{ .Values.serverHttpsPortName }}
containerPort: {{ .Values.serverHttpsPort }}

{{- toYaml .Values.securityContext | nindent 10 }}
resources:
Expand All @@ -54,7 +54,6 @@ spec:

{{ $apiServerUrl := required ".Values.clusterApiServer must be set. Refer to the values.yaml" .Values.clusterApiServer }}
env:

- name: CLUSTER_API_SERVER
value: {{ .Values.clusterApiServer }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,7 @@ metadata:
# https://docs.openshift.com/container-platform/4.7/networking/routes/route-configuration.html
haproxy.router.openshift.io/hsts_header: max-age=31536000;includeSubDomains;preload
spec:
{{ $subdomain := required ".Values.clusterAppsSubdomain must be set. Refer to the values.yaml" .Values.clusterAppsSubdomain }}

# do not put another . or the TLS cert domain will no longer match
{{ $host := printf "%s-%s.%s" .Values.appName .Release.Namespace .Values.clusterAppsSubdomain }}
# The host has to be the same for both client & server so we don't have to worry about CORS
host: {{ $host }}
path: /
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
to:
kind: Service
name: {{ .Values.clientServiceName }}
weight: 100

wildcardPolicy: None

---

apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: {{ .Values.appName }}-server
labels:
{{- toYaml .Values.commonLabels | nindent 4 }}
annotations:
haproxy.router.openshift.io/hsts_header: max-age=31536000;includeSubDomains;preload
spec:
# The host has to be the same for both client & server so we don't have to worry about CORS
host: {{ $host }}
path: /api
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
Expand All @@ -48,19 +18,3 @@ spec:
weight: 100

wildcardPolicy: None

---

# the ConsoleLink is in this file because it needs to know the frontend host

apiVersion: console.openshift.io/v1
kind: ConsoleLink
metadata:
name: {{ .Values.appName }}
labels:
{{- toYaml .Values.commonLabels | nindent 4 }}
spec:
{{ $href := printf "https://%s" $host }}
href: {{ $href }}
location: NamespaceDashboard
text: GitHub Connector
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,17 @@ metadata:
labels:
{{- toYaml .Values.commonLabels | nindent 4 }}
annotations:
service.alpha.openshift.io/serving-cert-secret-name: console-serving-cert
spec:
type: ClusterIP
selector:
{{- toYaml .Values.commonLabels | nindent 6 }}
ports:
- port: 80
targetPort: {{ .Values.serverPort }}
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.clientServiceName }}
labels:
{{- toYaml .Values.commonLabels | nindent 4 }}
annotations:
spec:
type: ClusterIP
selector:
{{ toYaml .Values.commonLabels | nindent 6 }}
ports:
- port: 80
targetPort: {{ .Values.clientPort }}
name: {{ .Values.serverHttpPortName }}
targetPort: {{ .Values.serverHttpPort }}
protocol: TCP

---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.pluginServiceName }}
labels:
{{- toYaml .Values.commonLabels | nindent 4 }}
annotations:
service.alpha.openshift.io/serving-cert-secret-name: console-serving-cert
spec:
type: ClusterIP
selector:
{{ toYaml .Values.commonLabels | nindent 6 }}
ports:
- port: 80
targetPort: {{ .Values.pluginPort }}
- port: 443
name: {{ .Values.serverHttpsPortName }}
targetPort: {{ .Values.serverHttpsPort }}
protocol: TCP
31 changes: 5 additions & 26 deletions containerize/chart/openshift-actions-connector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ securityContext:
drop:
- ALL


# REQUIRED VALUE:
# This is the apps.<cluster url> subdomain.which may have been edited by the admin. There does not appear to be a user API to get this.
# the easiest way to get this is to `oc expose <some service>` and then look at its subdomain
# "$(oc whoami --show-server | cut -d'/' -f3 | cut -d':' -f1 | sed -e 's/api/apps/')"
# https://github.com/helm/helm/issues/2055
clusterAppsSubdomain: ""

# REQUIRED VALUE
# oc whoami --show-server
clusterApiServer: ""
Expand Down Expand Up @@ -51,21 +43,8 @@ serverReplicaCount: 1
serverImage: quay.io/tetchell/openshift-actions-connector
serverTag: latest

serverServiceName: actions-connector-server
serverPort: 3003
serverPortName: server-port

################################################################################

# clientReplicaCount: 1

# clientImage: quay.io/tetchell/openshift-actions-connector-client
# clientTag: latest

clientServiceName: actions-connector-client
clientPort: 3000
clientPortName: client-port

pluginServiceName: actions-connector-plugin
pluginPort: 3001
pluginPortName: plugin-port
serverServiceName: actions-connector
serverHttpPort: 8080
serverHttpPortName: server-http
serverHttpsPort: 8443
serverHttpsPortName: server-https
39 changes: 0 additions & 39 deletions containerize/dev/Containerfile.dev

This file was deleted.

15 changes: 0 additions & 15 deletions containerize/dev/entrypoint.dev.sh

This file was deleted.

29 changes: 0 additions & 29 deletions containerize/entrypoint.sh

This file was deleted.

Loading

0 comments on commit 05d65be

Please sign in to comment.