Skip to content

Commit 2373b45

Browse files
authored
Merge pull request #32 from IBM-Cloud/issue_2845
Issue 2845 - Moving to Code Engine
2 parents 1ca1d05 + 08dbe64 commit 2373b45

File tree

12 files changed

+1674
-92
lines changed

12 files changed

+1674
-92
lines changed

.ceignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Files listed here will not be deployed. Similar to .gitignore function
2+
3+
node_modules/
4+
.cfignore
5+
.env
6+
.env.example
7+
__temp__ca.pem

.cfignore

Lines changed: 0 additions & 13 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
FROM node:14
1+
FROM node:16-alpine
22

33
# Create app directory
4-
RUN mkdir /src
4+
RUN mkdir /src
55
WORKDIR /src
66

7-
8-
97
# If you are building your code for production
108
# RUN npm ci --only=production
119

@@ -17,7 +15,6 @@ RUN npm install
1715
COPY ./server /src/server
1816
COPY ./public /src/public
1917
COPY ./server.js /src/server.js
20-
COPY ./.env /src/.env
2118

2219
ENV PORT 8080
2320
EXPOSE 8080

README.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a basic boilerplate for the MEAN stack ([MongoDB](https://www.mongodb.org/), [Express](http://expressjs.com/), [AngularJS](https://angularjs.org/) and [Node.js](https://nodejs.org)) on [IBM Cloud](https://cloud.ibm.com).
44

5-
This application uses the [IBM Cloud Databases for MongoDB service](https://cloud.ibm.com/catalog/services/databases-for-mongodb) and [Node.js runtime](https://cloud.ibm.com/docs/runtimes/nodejs?topic=Nodejs-nodejs_runtime) on IBM Cloud.
5+
This application uses [Databases for MongoDB](https://cloud.ibm.com/catalog/services/databases-for-mongodb) and [Code Engine](https://cloud.ibm.com/codeengine) on IBM Cloud.
66

77
The code and detailed steps are discussed in the [IBM Cloud solution tutorial](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-tutorials) titled [Modern web application using MEAN stack](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-mean-stack).
88

@@ -21,13 +21,12 @@ The code and detailed steps are discussed in the [IBM Cloud solution tutorial](h
2121
## Application Requirements
2222
- [Node.js & NPM](https://nodejs.org/en/download/)
2323
- [IBM Cloud Databases for MongoDB](https://cloud.ibm.com/catalog/services/databases-for-mongodb)
24-
- [Cloud Foundry Command Line Tool](https://docs.cloudfoundry.org/devguide/installcf/)
24+
- [Code Engine Command Line Tool](https://cloud.ibm.com/docs/codeengine?topic=codeengine-cli)
2525

2626
## Files & Folders
2727

2828
| File | Description |
2929
| ---------------------------------- | ------------------------------------------------------------ |
30-
| [**manifest.yml**](./manifest.yml) | File that defines deployment paramaters. [More info here](http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html)
3130
| [**.env.example**](./.env.example) | Set custom [environment variables](https://en.wikipedia.org/wiki/Environment_variable) for your application. This is the proper way to store credentials and other sensitive values.
3231
| [**server.js**](./server.js) | Main server file that the Node.js runtime uses. It contains all the server logic.
3332
| [**/server**](./server) | Folder for files used by the Node.js server
@@ -50,9 +49,9 @@ There is also generous commenting throughout the application which helps explain
5049
1. Open application directory in your terminal and run `npm install`
5150
1. If you don't have an account, [create a free one here](https://cloud.ibm.com).
5251
1. Login to your account via the command line: `ibmcloud login`
53-
1. Target your account ORG and SPACE `ibmcloud target --cf`
54-
1. Create the instance of IBM Cloud Databases for MongoDB on IBM Cloud: `ibmcloud cf create-service databases-for-mongodb standard mean-starter-mongodb`
55-
1. Rename `.env.example` file to `.env` and run `ibmcloud cf service-key mean-starter-mongodb "Service credentials-1"` for MONGODB_URL and CERTIFICATE_BASE64. Choose your own SESSION_SECRET.
52+
1. Target your desired region `ibmcloud target -r ca-tor`
53+
1. Create the instance of Databases for MongoDB on IBM Cloud: `ibmcloud resource service-instance-create mean-starter-mongodb databases-for-mongodb standard ca-tor`
54+
1. Copy `.env.example` file to `.env`. Edir `.env` to fill it the required values. You can run `ibmcloud resource service-key-create mean-starter-mongodb-key --instance-name mean-starter-mongodb` to obtain the MONGODB_URL and CERTIFICATE_BASE64. Choose your own SESSION_SECRET.
5655
1. Run `node server.js` to start your app
5756
1. Open a browser to the link provided in the terminal prompt to view your app
5857

@@ -65,26 +64,18 @@ An alternative way of running locally is using the provided `Dockerfile`.
6564
```
6665
- Run the app locally
6766
```
68-
docker run -p 8080:8080 -ti mean-stack:v1.0.0
67+
docker run -p 8080:8080 --env-file .env -ti mean-stack:v1.0.0
6968
```
7069

7170
## Contribute
7271
Please create a pull request with your desired changes.
7372

7473
## Troubleshooting
75-
The primary source of debugging information for your app is the logs. To see them, run the following Cloud Foundry command using the IBM Cloud CLI:
74+
The primary source of debugging information for your app running in the cloud are the logs. To see them, use the [Code Engine](https://cloud.ibm.com/codeengine/projects) wbe interface.
7675

77-
```
78-
$ ibmcloud cf logs <application-name> --recent
79-
```
80-
81-
If you are not sure what your application name is, use this command to print your application name(s):
82-
83-
```
84-
$ ibmcloud cf apps
85-
```
76+
<img src="ReadME-Images/log-mon.png">
8677

87-
For more detailed information on troubleshooting your application, see the [Troubleshooting section](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-ts-cf-apps) in the documentation.
78+
For more detailed information on troubleshooting your application, see the [Troubleshooting apps section](https://cloud.ibm.com/docs/codeengine?topic=codeengine-troubleshoot-apps) in the documentation.
8879

8980
## License
9081
See [LICENSE.MD](https://github.com/IBM-Cloud/nodejs-MEAN-stack/blob/master/LICENSE.md) for license information.

ReadME-Images/Architecture.png

-8.05 KB
Loading

ReadME-Images/log-mon.png

99.8 KB
Loading

create-container-image.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Create Container Image
2+
3+
## Using Docker build commands
4+
5+
You will use the provided `Dockerfile`.
6+
- Install docker on your machine and build the docker image
7+
```
8+
docker build . -t mean-stack:v1.0.0
9+
```
10+
- Run the app locally to verify it works as expected
11+
```
12+
docker run -p 8080:8080 --env-file .env -ti mean-stack:v1.0.0
13+
14+
- Login to your container registry.
15+
> Note: If using the IBM Cloud Container registry, don't forget to use `ibmcloud cr login`
16+
17+
- Tag the image with your container registry's namespace/repository name.
18+
> Note:For IBM Cloud Container Registry in the US: `docker tag mean-stack:v1.0.0 us.icr.io/<namespace>/mean-stack:1.0.0`
19+
20+
- Push the image.
21+
> Note: For IBM Cloud Container Registry in the US: `docker push mean-stack:v1.0.0 us.icr.io/<namespace>/mean-stack:1.0.0`
22+
23+
- If you are using IBM Cloud Code Engine to run your container image and the containter registry used is the IBM Cloud Container Registry or a non-Public registry, you will be required to setup a secret for reading the image. Follow the steps outlined in here: https://cloud.ibm.com/docs/codeengine?topic=codeengine-add-registry to do just that.

manifest.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)