Committing work for creating docker images of Web and API apps
Outstanding work include: - Adding CI/CD workflow compatible with Woodpecker CI - Figure out how to load runtime environment variables onto the API docker build process
This commit is contained in:
@ -1,13 +1,28 @@
|
||||
# https://www.knowledgehut.com/blog/web-development/how-to-dockerize-react-app
|
||||
FROM node:17-alpine as builder
|
||||
WORKDIR /app
|
||||
COPY package-lock.json .
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm build
|
||||
|
||||
FROM nginx:latest
|
||||
# Set the environment variables
|
||||
ENV API_BASE_URL=
|
||||
ENV AUTH0_DOMAIN=
|
||||
ENV AUTH0_CLIENT_ID=
|
||||
ENV AUTH0_CALLBACK_URL=
|
||||
ENV AUTH0_AUDIENCE=
|
||||
|
||||
WORKDIR /app
|
||||
COPY package.json .
|
||||
RUN npm install
|
||||
|
||||
RUN echo 'DEBUG': $API_BASE_URL
|
||||
RUN echo 'DEBUG': $AUTH0_DOMAIN
|
||||
RUN echo 'DEBUG': $AUTH0_CLIENT_ID
|
||||
RUN echo 'DEBUG': $AUTH0_CALLBACK_URL
|
||||
RUN echo 'DEBUG': $AUTH0_AUDIENCE
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:mainline-alpine
|
||||
WORKDIR /usr/share/nginx/html
|
||||
RUN rm -rf ./*
|
||||
COPY --from=builder /app/build .
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||
@ -68,3 +68,17 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/d
|
||||
### `npm run build` fails to minify
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
||||
|
||||
---
|
||||
## Docker
|
||||
|
||||
To build a dockerized version of the Web project:
|
||||
|
||||
```
|
||||
docker build { WEB_PROJECT_ROOT_SOURCE } -f { WEB_PROJECT_DOCKERFILE_PATH } -t { imagename:tag }
|
||||
```
|
||||
|
||||
In order to run a container using the image built above, keep the following things in mind:
|
||||
- It might be necessary to map container port 80 to another
|
||||
- Environment variables actively used by the web app can be overriden when starting uip a container. They are prefixed with: `REACT_APP`
|
||||
- Environment variables that are explicitly listed in `Web\Dockerfile` will have to be properly set for proper operation of the application
|
||||
|
||||
22151
Web/package-lock.json
generated
22151
Web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
||||
"name": "yaba-web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"homepage": ".",
|
||||
"dependencies": {
|
||||
"@auth0/auth0-react": "^2.0.0",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
|
||||
Reference in New Issue
Block a user