Skip to content

Commit 1bf8069

Browse files
committed
chore: basic generation + devcontainer plugin
0 parents  commit 1bf8069

390 files changed

Lines changed: 16435 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/admin/.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.dockerignore
2+
docker-compose.yml
3+
Dockerfile
4+
build/
5+
node_modules
6+
.env
7+
.gitignore

app/admin/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PORT=3001
2+
REACT_APP_SERVER_URL=http://localhost:3000

app/admin/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

app/admin/Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# multi-stage: base (build)
2+
FROM node:18.13.0-slim AS base
3+
4+
# instantiate environment variable
5+
ARG REACT_APP_SERVER_URL=http://localhost:3000
6+
7+
# set the environment variable that points to the server
8+
ENV REACT_APP_SERVER_URL=$REACT_APP_SERVER_URL
9+
10+
# create directory where the application will be built
11+
WORKDIR /app
12+
13+
# copy over the dependency manifests, both the package.json
14+
# and the package-lock.json are copied over
15+
COPY package*.json ./
16+
17+
# installs packages and their dependencies
18+
RUN npm install
19+
20+
# copy over the code base
21+
COPY . .
22+
23+
# create the bundle of the application
24+
RUN npm run build
25+
26+
# multi-stage: production (runtime)
27+
FROM nginx:1.22-alpine AS production
28+
29+
# copy over the bundled code from the build stage
30+
COPY --from=base /app/build /usr/share/nginx/html
31+
COPY --from=base /app/configuration/nginx.conf /etc/nginx/conf.d/default.conf
32+
33+
# create a new process indication file
34+
RUN touch /var/run/nginx.pid
35+
36+
# change ownership of nginx related directories and files
37+
RUN chown -R nginx:nginx /var/run/nginx.pid \
38+
/usr/share/nginx/html \
39+
/var/cache/nginx \
40+
/var/log/nginx \
41+
/etc/nginx/conf.d
42+
43+
# set user to the created non-privileged user
44+
USER nginx
45+
46+
# expose a specific port on the docker container
47+
ENV PORT=3001
48+
EXPOSE ${PORT}
49+
50+
# start the server using the previously build application
51+
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]

app/admin/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<p align="right">
2+
<a href="https://amplication.com" target="_blank">
3+
<img alt="amplication-logo" height="70" alt="Amplication Logo" src="https://amplication.com/images/amplication-logo-purple.svg"/>
4+
</a>
5+
</p>
6+
7+
# Introduction
8+
9+
This service was generated with Amplication. It serves as the client-side for the generated server component. The client-side consist of a React application with ready-made forms for creating and editing the different data models of the application. It is pre-conffigured to work with the server and comes with the boilerplate and foundation for the client - i.e., routing, navigation, authentication, permissions, menu, breadcrumbs, error handling and much more. Additional information about the admin component and the architecture around it, can be found on the [documentation](https://docs.amplication.com/guides/getting-started) site. This side of the generated project was bootstrapped with [create-react-app](https://github.com/facebook/create-react-app) and built with [react-admin](https://marmelab.com/react-admin/).
10+
11+
12+
<p align="center">
13+
<img src="https://d33wubrfki0l68.cloudfront.net/2615bedd21c48089ab38a099bad9638b28879511/091b4/assets/images/admin-ui-9b6590728393d532ad798e9dc14138ac.png" width="700px">
14+
</p>
15+
16+
# Getting started
17+
18+
## Step 1: Configuration
19+
20+
Configuration for the client component can be provided through the use of environment variables. These can be passed to the application via the use of the `.env` file in the base directory of the generated service. Below a table can be found which show the different variables that can be passed. These values are provided default values after generation, change them to the desired values.
21+
22+
| Variable | Description | Value |
23+
| -------------------- | ------------------------------------------------ | ------------------------------ |
24+
| PORT | the port on which to run the client | 3001 |
25+
| REACT_APP_SERVER_URL | the url on which the server component is running | http://localhost:[server-port] |
26+
27+
> **Note**
28+
> Amplication generates default values and stores them under the .env file. It is advised to use some form of secrets manager/vault solution when using in production.
29+
30+
31+
## Step 2: Scripts
32+
33+
After configuration of the client the next step would be to run the application. Before running the client side of the component, make sure that the different pre-requisites are met - i.e., npm, docker. Make sure that the server-side of the application is running.
34+
35+
```sh
36+
# installation of the dependencies
37+
$ npm install
38+
39+
# starts the application in development mode - available by default under http://localhost:3001 with a pre-configured user with the username "admin" and password "admin"
40+
$ npm run start
41+
42+
# builds the application in production mode - available under 'build'
43+
$ npm run build
44+
45+
# removes the single build dependency from the project
46+
$ npm run eject
47+
```

app/admin/configuration/nginx.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server_tokens off;
2+
3+
server {
4+
listen 80;
5+
server_name localhost;
6+
location / {
7+
root /usr/share/nginx/html;
8+
index index.html index.htm;
9+
try_files $uri /index.html;
10+
}
11+
}

app/admin/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3.8"
2+
3+
services:
4+
admin-ui:
5+
container_name: admin-ui-container
6+
image: admin-ui-image
7+
build:
8+
context: .
9+
ports:
10+
- 3001:80

app/admin/package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "@sample-application/admin",
3+
"version": "0.1.3",
4+
"private": true,
5+
"dependencies": {
6+
"@apollo/client": "3.6.9",
7+
"@material-ui/core": "4.12.4",
8+
"graphql": "15.6.1",
9+
"lodash": "4.17.21",
10+
"pluralize": "8.0.0",
11+
"ra-data-graphql-amplication": "0.0.14",
12+
"react": "16.14.0",
13+
"react-admin": "3.19.12",
14+
"react-dom": "16.14.0",
15+
"react-scripts": "5.0.0",
16+
"sass": "^1.39.0",
17+
"web-vitals": "1.1.2"
18+
},
19+
"overrides": {
20+
"react-scripts": {
21+
"@svgr/webpack": "6.5.1"
22+
}
23+
},
24+
"scripts": {
25+
"start": "react-scripts start",
26+
"build": "react-scripts build",
27+
"test": "react-scripts test",
28+
"eject": "react-scripts eject",
29+
"package:container": "docker build ."
30+
},
31+
"eslintConfig": {
32+
"extends": [
33+
"react-app",
34+
"react-app/jest"
35+
]
36+
},
37+
"browserslist": {
38+
"production": [
39+
">0.2%",
40+
"not dead",
41+
"not op_mini all"
42+
],
43+
"development": [
44+
"last 1 chrome version",
45+
"last 1 firefox version",
46+
"last 1 safari version"
47+
]
48+
},
49+
"devDependencies": {
50+
"@testing-library/jest-dom": "5.14.1",
51+
"@testing-library/react": "11.2.7",
52+
"@testing-library/user-event": "13.2.0",
53+
"@types/jest": "26.0.16",
54+
"@types/lodash": "4.14.178",
55+
"@types/node": "12.20.16",
56+
"@types/react": "16.14.11",
57+
"@types/react-dom": "17.0.0",
58+
"type-fest": "0.13.1",
59+
"typescript": "4.3.5"
60+
}
61+
}

app/admin/public/favicon.ico

3.78 KB
Binary file not shown.

app/admin/public/index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta name="description" content="Sample application for testing" />
9+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
10+
<!--
11+
manifest.json provides metadata used when your web app is installed on a
12+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
13+
-->
14+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
15+
<!--
16+
Notice the use of %PUBLIC_URL% in the tags above.
17+
It will be replaced with the URL of the `public` folder during the build.
18+
Only files inside the `public` folder can be referenced from the HTML.
19+
20+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
21+
work correctly both with client-side routing and a non-root public URL.
22+
Learn how to configure a non-root public URL by running `npm run build`.
23+
-->
24+
<title>Sample Application</title>
25+
</head>
26+
<body>
27+
<noscript>You need to enable JavaScript to run this app.</noscript>
28+
<div id="root"></div>
29+
<!--
30+
This HTML file is a template.
31+
If you open it directly in the browser, you will see an empty page.
32+
33+
You can add webfonts, meta tags, or analytics to this file.
34+
The build step will place the bundled scripts into the <body> tag.
35+
36+
To begin the development, run `npm start` or `yarn start`.
37+
To create a production bundle, use `npm run build` or `yarn build`.
38+
-->
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)