Commit bf69907a authored by Caetan Tojeiro Carpente's avatar Caetan Tojeiro Carpente
Browse files

[#19] Fix web-portal Dockerfile

parent 8ffa34bf
Pipeline #2233846 passed with stages
in 5 minutes and 30 seconds
node_modules
npm-debug.log
README.md
.vscode
......@@ -6,21 +6,10 @@ variables:
RESOURCE: web-portal-image-stream
stages:
- Build_App
- Build
- Tag_Image
- Import_Image
.build_app:
stage: Build_App
image: node:12-alpine
script:
- yarn install
- npx env-cmd -f ".env.$BUILD_ENV" yarn build
artifacts:
paths:
- build
.build:
stage: Build
tags:
......@@ -42,16 +31,6 @@ stages:
script:
- oc import-image ${RESOURCE}:${TAG} --token=${TOKEN} --server=${OPENSHIFT_SERVER} -n ${NAMESPACE}
build_app:
extends: .build_app
variables:
BUILD_ENV: ${BUILD_ENV_DEV}
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
- if: $CI_COMMIT_TAG || $CI_COMMIT_BRANCH == 'master'
- when: never
# Build image and store it in the registry.
build:
extends: .build
......
FROM node:alpine AS build
WORKDIR /usr/src/app
COPY . .
RUN apk update && apk add python2 build-base && npm install && npm run build
FROM node:alpine
WORKDIR /usr/src/app
COPY ./build .
COPY --from=build /usr/src/app/build ./build
RUN yarn global add serve
RUN npm install -g serve
EXPOSE 5000
EXPOSE 3000
CMD serve -s -p 3000 .
CMD ["serve", "-s", "build", "-l", "3000"]
## System requirements
- [Nodejs](https://nodejs.org/en/)
- [Yarn](https://classic.yarnpkg.com/en/docs/install)
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
## Start web portal application
1. In the root folder run
```
yarn install
npm install
```
2. After installing all the dependencies, you should be able to run the project
```
yarn start
```
```
npm start
```
## Test docker image locally
The Dockerfile is meant to build the image that is going to be used in the production environment,
so it expects to use the production build of the web-portal application. So first of all we should build the application:
```
npx env-cmd -f .env cross-env yarn build
```
When the build is finished, we can build the docker image to test the production build of the system:
We can build the docker image to test the production build of the system:
```
docker build . -t web-portal
```
Once it is built, we can run the container with the app listening on `http://localhost:3000`:
```
docker run -p 3000:3000 web-portal
```
......@@ -40,7 +40,7 @@
"start": "HTTPS=true npm-run-all -p watch-css start-js",
"build-js": "react-scripts build",
"build": "npm-run-all build-css build-js",
"build-dev": "npx env-cmd -f .env cross-env yarn build",
"build-dev": "npx env-cmd -f .env cross-env npm build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"start-prod": "serve -s ./build"
......
......@@ -38,8 +38,8 @@
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment