Skip to content

Commit ed92888

Browse files
committed
Updated to use Code Engine
1 parent a26acd6 commit ed92888

File tree

8 files changed

+32
-58
lines changed

8 files changed

+32
-58
lines changed

Dockerfile

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

33
# Create app directory
4-
5-
# RUN mkdir /src
6-
# This command above fails on Code Engine:
7-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk #5 [2/8] RUN mkdir /src
8-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk #5 0.079 container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: mountpoint for devices not found
9-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk #5 ERROR: process "/bin/sh -c mkdir /src" did not complete successfully: exit code: 1
10-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk ------
11-
# > [2/8] RUN mkdir /src:
12-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk #5 0.079 container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: mountpoint for devices not found
13-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk ------
14-
# Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk Dockerfile:4
15-
## Feb 3 06:02:21 Code Engine mean-stack-local-build-run-220203-060041645-cb7j7-pod-zflpk --------------------
16-
# 2 |
17-
# 3 | # Create app directory
18-
# 4 | >>> RUN mkdir /src
19-
# 5 | WORKDIR /src
20-
# 6 |
21-
4+
RUN mkdir /src
225
WORKDIR /src
236

24-
25-
267
# If you are building your code for production
278
# RUN npm ci --only=production
289

@@ -31,7 +12,7 @@ COPY ./package*.json /src/
3112
RUN npm install
3213

3314
# Bundle app source
34-
COPY ./models /src/models
15+
COPY ./server /src/server
3516
COPY ./public /src/public
3617
COPY ./server.js /src/server.js
3718

README.md

Lines changed: 1 addition & 1 deletion
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 the [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

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 forger 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 tag 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.

server.js

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ const LocalStrategy = require('passport-local').Strategy;
1414

1515
// MongoDB connection library
1616
const mongoose = require('mongoose');
17-
const User = require('./models/user.model');
17+
const User = require('./server/models/user.model');
1818

1919
/********************************
2020
Load environment
2121
********************************/
22-
// const appEnv = require('cfenv').getAppEnv();
23-
// if (appEnv.isLocal) {
24-
require('dotenv').config();// Loads .env file into environment
25-
// }
22+
require('dotenv').config();// Loads .env file into environment
2623

2724
/********************************
2825
MongoDB Connection
@@ -31,20 +28,8 @@ async function initializeDatabase() {
3128
//Detects environment and connects to appropriate DB
3229
var caCertificateBase64, mongoDbUrl;
3330

34-
// if (appEnv.isLocal) {
35-
caCertificateBase64 = process.env.CERTIFICATE_BASE64;
36-
mongoDbUrl = process.env.MONGODB_URL;
37-
// }
38-
// // Connect to MongoDB Service on IBM Cloud
39-
// else if (!appEnv.isLocal) {
40-
// var mongoDbCredentials = appEnv.services["databases-for-mongodb"][0].credentials.connection.mongodb;
41-
// caCertificateBase64 = mongoDbCredentials.certificate.certificate_base64
42-
// mongoDbUrl = mongoDbCredentials.composed[0];
43-
// }
44-
// else {
45-
// console.log('No configuration found to connect to MongoDB.');
46-
// System.exit(1);
47-
// }
31+
caCertificateBase64 = process.env.CERTIFICATE_BASE64;
32+
mongoDbUrl = process.env.MONGODB_URL;
4833

4934
function unicodeToChar(text) {
5035
return text.replace(/\\u[\dA-F]{4}/gi,
@@ -126,13 +111,7 @@ function configureApp() {
126111
app.use(bodyParser.json());
127112
app.use(bodyParser.urlencoded({ extended: true }));
128113
app.use(cookieParser());
129-
// app.use(session({
130-
// secret: process.env.SESSION_SECRET || 'this_is_a_default_session_secret_in_case_one_is_not_defined',
131-
// resave: true,
132-
// store: new MongoStore({ client: mongoose.connection.getClient() }),
133-
// saveUninitialized: false,
134-
// cookie: { secure: !appEnv.isLocal }
135-
// }));
114+
136115
app.use(session({
137116
secret: process.env.SESSION_SECRET || 'this_is_a_default_session_secret_in_case_one_is_not_defined',
138117
resave: true,
File renamed without changes.

0 commit comments

Comments
 (0)