|
| 1 | +# TypeScript Sample Application |
| 2 | + |
| 3 | +This repository provides a simple starting point for running TypeScript |
| 4 | +applications on OpenShift. It can also be applied to applications that use |
| 5 | +Babel or other transpilers. |
| 6 | + |
| 7 | +A blogpost that runs through the details of this repository and OpenShift can |
| 8 | +be found [here](http://evanshortiss.com/development/openshift/javascript/typescript/2018/02/15/ts-on-openshift.html). |
| 9 | + |
| 10 | +You can use this repository as a template, just click the green "Use this |
| 11 | +template" button at the top of this page on GitHub. |
| 12 | + |
| 13 | +## Running on OpenShift via NodeShift |
| 14 | +To use this method of deployment you'll need: |
| 15 | + |
| 16 | +* Node.js v12 or later |
| 17 | +* OpenShift 4.x (Run OpenShift 4.x locally using [CodeReady Containers](https://developers.redhat.com/products/codeready-containers/overview)) |
| 18 | + |
| 19 | +NodeShift is a neat CLI that simplifies deployment of Node.js applications on |
| 20 | +OpenShift. This project incldues NodeShift in `devDependencies`. |
| 21 | + |
| 22 | +You can run the following to deploy it on an OpenShift instance: |
| 23 | + |
| 24 | +``` |
| 25 | +$ git clone [email protected]:evanshortiss/openshift-typescript-example.git ts-openshift |
| 26 | +
|
| 27 | +$ cd ts-openshift |
| 28 | +
|
| 29 | +# Ensure you are logged into your openshift instance |
| 30 | +$ oc login |
| 31 | +
|
| 32 | +# Choose the project you'd like to deploy this applicaion into |
| 33 | +$ oc new-project ts-example |
| 34 | +
|
| 35 | +# Build, deploy, and expose an endpoint for the service |
| 36 | +$ npm run nodeshift -- --expose |
| 37 | +``` |
| 38 | + |
| 39 | +If you're deploying on a locally running instance of OpenShift you might need |
| 40 | +to do the following to bypass the self-signed certificate issues: |
| 41 | + |
| 42 | +``` |
| 43 | +$ npm run nodeshift -- --expose --strictSSL=false |
| 44 | +``` |
| 45 | + |
| 46 | +## Run Locally without Docker |
| 47 | +To run this application locally you'll need: |
| 48 | + |
| 49 | +* Node.js v12 or later |
| 50 | +* npm v6 or later |
| 51 | +* Git |
| 52 | + |
| 53 | +Execute the following commands to start the program locally: |
| 54 | + |
| 55 | +``` |
| 56 | +git clone [email protected]:evanshortiss/openshift-typescript-example.git ts-openshift |
| 57 | +
|
| 58 | +cd ts-openshift |
| 59 | +
|
| 60 | +npm instal |
| 61 | +npm run build |
| 62 | +npm start |
| 63 | +``` |
| 64 | + |
| 65 | +If you're developing locally, start a live reload server like so: |
| 66 | + |
| 67 | +``` |
| 68 | +npm run start-dev |
| 69 | +``` |
| 70 | + |
| 71 | +## Build Locally using Source-to-Image (s2i) |
| 72 | +To perform the following steps you'll need: |
| 73 | + |
| 74 | +* [Docker](https://docs.docker.com/release-notes/) (v19.x tested) |
| 75 | +* [s2i](https://github.com/openshift/source-to-image/releases) (v1.1.13 tested) |
| 76 | + |
| 77 | +With both tools installed, execute the following commands to run your |
| 78 | +application locally. This will create a container that matches the one created |
| 79 | +using an OpenShift Build. |
| 80 | + |
| 81 | +```bash |
| 82 | +# Run the s2i build script |
| 83 | +./scripts/s2i.sh |
| 84 | + |
| 85 | +# Run the container image |
| 86 | +docker run -p 8080:8080 quay.io/evanshortiss/openshift-s2i-typescript-example |
| 87 | +``` |
| 88 | + |
| 89 | +## Running Local Dev Mode using Docker Compose |
| 90 | +To perform the following steps you'll need: |
| 91 | + |
| 92 | +* [Docker](https://docs.docker.com/release-notes/) (v19.x tested) |
| 93 | +* [Docker Compose](https://docs.docker.com/compose/install/) |
| 94 | + |
| 95 | +Run the `docker-compose up` command from the root of the repository to start |
| 96 | +Node.js and Redis containers. |
| 97 | + |
| 98 | +The application will be available on port 8080. |
0 commit comments