Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions admin-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
FROM node:16-alpine AS base
FROM node:16.16 AS base

# Define how verbose should npm install be
ARG NPM_LOG_LEVEL=silent
# Hide Open Collective message from install logs
ENV OPENCOLLECTIVE_HIDE=1
# Hiden NPM security message from install logs
ENV NPM_CONFIG_AUDIT=false
# Hide NPM funding message from install logs
ENV NPM_CONFIG_FUND=false
ARG REACT_APP_SERVER_URL

# Update npm to version 7
RUN npm i -g npm@8.1.2
ENV REACT_APP_SERVER_URL=$REACT_APP_SERVER_URL

# Set the working directory
WORKDIR /app/admin-ui
WORKDIR /app

# Copy files specifying dependencies
COPY package.json package-lock.json ./

# Install dependencies
RUN npm ci --loglevel=$NPM_LOG_LEVEL;
RUN npm ci

# Copy all the files
COPY . .

# Build code
RUN npm run build

# Expose the port the client listens to
EXPOSE 3001
FROM nginx:stable-alpine AS prod

# Run admin-ui
COPY --from=base /app/build /usr/share/nginx/html

CMD [ "npm", "start"]
EXPOSE 80

ENTRYPOINT ["nginx", "-g", "daemon off;"]
28,114 changes: 0 additions & 28,114 deletions admin-ui/package-lock.json

This file was deleted.

8 changes: 3 additions & 5 deletions admin-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"name": "@sample-app/admin",
"name": "@human-file-system/admin",
"private": true,
"dependencies": {
"@apollo/client": "3.6.9",
"@material-ui/core": "4.12.4",
"gql": "1.1.2",
"graphql": "15.6.1",
"graphql-tag": "2.12.4",
"lodash": "4.17.21",
"pluralize": "8.0.0",
"ra-data-graphql-amplication": "0.0.13",
Expand All @@ -15,7 +13,6 @@
"react-dom": "16.14.0",
"react-scripts": "5.0.0",
"sass": "^1.39.0",
"typescript": "4.2.4",
"web-vitals": "1.1.2"
},
"scripts": {
Expand Down Expand Up @@ -52,6 +49,7 @@
"@types/node": "12.20.16",
"@types/react": "16.14.11",
"@types/react-dom": "17.0.0",
"type-fest": "0.13.1"
"type-fest": "0.13.1",
"typescript": "4.2.4"
}
}
6 changes: 4 additions & 2 deletions admin-ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Sample application for e-commerce" />
<meta name="description" content="Don’t you hate how you and everyone you’ve ever loved are going to suffer and die of horrible diseases? If so, then join us!

We’re working to create 7 billion digital twins that can exponentially accelerate the pace of clinical discovery through digital clinical trials." />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -21,7 +23,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Sample app</title>
<title>Human File System</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
4 changes: 2 additions & 2 deletions admin-ui/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "Sample app",
"name": "Sample app",
"short_name": "Human File System",
"name": "Human File System",
"icons": [
{
"src": "favicon.ico",
Expand Down
6 changes: 3 additions & 3 deletions admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ProductList } from "./product/ProductList";
import { ProductCreate } from "./product/ProductCreate";
import { ProductEdit } from "./product/ProductEdit";
import { ProductShow } from "./product/ProductShow";
import { jwtAuthProvider } from "./auth-provider/ra-auth-jwt";
import { httpAuthProvider } from "./auth-provider/ra-auth-http";

const App = (): React.ReactElement => {
const [dataProvider, setDataProvider] = useState<DataProvider | null>(null);
Expand All @@ -44,9 +44,9 @@ const App = (): React.ReactElement => {
return (
<div className="App">
<Admin
title={"Sample app"}
title={"Human File System"}
dataProvider={dataProvider}
authProvider={jwtAuthProvider}
authProvider={httpAuthProvider}
theme={theme}
dashboard={Dashboard}
loginPage={Login}
Expand Down
4 changes: 3 additions & 1 deletion admin-ui/src/api/user/User.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { JsonValue } from "type-fest";

export type User = {
createdAt: Date;
firstName: string | null;
id: string;
lastName: string | null;
roles: Array<string>;
roles: JsonValue;
updatedAt: Date;
username: string;
};
4 changes: 3 additions & 1 deletion admin-ui/src/api/user/UserCreateInput.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { InputJsonValue } from "../../types";

export type UserCreateInput = {
firstName?: string | null;
lastName?: string | null;
password: string;
roles: Array<string>;
roles: InputJsonValue;
username: string;
};
4 changes: 3 additions & 1 deletion admin-ui/src/api/user/UserUpdateInput.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { InputJsonValue } from "../../types";

export type UserUpdateInput = {
firstName?: string | null;
lastName?: string | null;
password?: string;
roles?: Array<string>;
roles?: InputJsonValue;
username?: string;
};
2 changes: 1 addition & 1 deletion admin-ui/src/user/UserCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const UserCreate = (props: CreateProps): React.ReactElement => {
<TextInput label="Last Name" source="lastName" />
<PasswordInput label="Password" source="password" />
<SelectArrayInput
source="roles"
source="roles.roles"
choices={ROLES_OPTIONS}
optionText="label"
optionValue="value"
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/src/user/UserEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const UserEdit = (props: EditProps): React.ReactElement => {
<TextInput label="Last Name" source="lastName" />
<PasswordInput label="Password" source="password" />
<SelectArrayInput
source="roles"
source="roles.roles"
choices={ROLES_OPTIONS}
optionText="label"
optionValue="value"
Expand Down
10 changes: 5 additions & 5 deletions server/.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
POSTGRESQL_USER=admin
POSTGRESQL_PASSWORD=admin
POSTGRESQL_PORT=5432
POSTGRESQL_URL=postgres://admin:admin@localhost:5432
BCRYPT_SALT=10
COMPOSE_PROJECT_NAME=amp_cl6zoypmi105503901jhyu0q1nna
JWT_SECRET_KEY=Change_ME!!!
JWT_EXPIRATION=2d
SERVER_PORT = 3000
SERVER_PORT=3000
DB_USER=admin
DB_PASSWORD=admin
DB_PORT=5432
DB_URL=postgres://admin:admin@localhost:5432
45 changes: 18 additions & 27 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
FROM node:16-alpine AS base
FROM node:16.16 AS base

# Define how verbose should npm install be
ARG NPM_LOG_LEVEL=silent
# Hide Open Collective message from install logs
ENV OPENCOLLECTIVE_HIDE=1
# Hiden NPM security message from install logs
ENV NPM_CONFIG_AUDIT=false
# Hide NPM funding message from install logs
ENV NPM_CONFIG_FUND=false
WORKDIR /app

# Update npm to version 7
RUN npm i -g npm@8.1.2

# Set the working directory
WORKDIR /app/server

# Copy files specifying dependencies
COPY package.json package-lock.json ./

# Install dependencies
RUN npm ci --loglevel=$NPM_LOG_LEVEL;
RUN npm ci

# Copy Prisma schema
COPY prisma/schema.prisma ./prisma/

# Generate Prisma client
RUN npm run prisma:generate;
RUN npm run prisma:generate

# Copy all the files
COPY . .
COPY . .

# Build code
RUN npm run build

# Expose the port the server listens to
FROM node:16.16 AS prod

WORKDIR /app

COPY --from=base /app/node_modules/ ./node_modules
COPY --from=base /app/package.json ./package.json
COPY --from=base /app/dist ./dist
COPY --from=base /app/prisma ./prisma
COPY --from=base /app/scripts ./scripts
COPY --from=base /app/src ./src
COPY --from=base /app/tsconfig* .

EXPOSE 3000

# Run server
CMD [ "node", "dist/main"]
CMD [ "node", "./dist/main"]
24 changes: 13 additions & 11 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ Your app is ready to be deployed!

## Environment Variables:

| Environment | Description | Value |
| -------------------- | ---------------------------------------- | ----------------------------------------------------------- |
| DEBUG_MODE | Debug level | 1 |
| POSTGRESQL_URL | Local database connection URL | postgresql://admin:admin@localhost:5432/\${SERVICE_DB_NAME} |
| POSTGRESQL_PORT | Local database port | 5432 |
| POSTGRESQL_USER | Local database username | admin |
| POSTGRESQL_PASSWORD | Local database password | admin |
| COMPOSE_PROJECT_NAME | Docker Compose project name | amp\_{applicationId} |
| SERVER_PORT | The port that the server is listening to | 3000 |
| JWT_SECRET_KEY | JWT secret | Change_ME!!! |
| JWT_EXPIRATION | JWT expiration in days | 2d |
| Environment | Description | Value |
| -------------------- | ---------------------------------------- | ---------------------------------------------------------- |
| DEBUG_MODE | Debug level | 1 |
| DB_URL | Local database connection URL | db-provider://admin:admin@localhost:${DB_PORT}/\${DB_NAME} |
| DB_PORT | Local database port | |
| DB_USER | Local database username | admin |
| DB_PASSWORD | Local database password | admin |
| COMPOSE_PROJECT_NAME | Docker Compose project name | amp\_{applicationId} |
| SERVER_PORT | The port that the server is listening to | 3000 |
| JWT_SECRET_KEY | JWT secret | Change_ME!!! |
| JWT_EXPIRATION | JWT expiration in days | 2d |

\*db-provider - the prisma DB provider (for example: for postgres is postgresql and for MySQL is mysql)

## Getting Started - Local Development

Expand Down
6 changes: 3 additions & 3 deletions server/docker-compose.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ services:
db:
image: postgres:12
ports:
- "${POSTGRESQL_PORT}:5432"
- ${DB_PORT}:5432
environment:
POSTGRES_USER: ${POSTGRESQL_USER}
POSTGRES_PASSWORD: ${POSTGRESQL_PASSWORD}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres:/var/lib/postgresql/data
volumes:
Expand Down
37 changes: 18 additions & 19 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ services:
args:
NPM_LOG_LEVEL: notice
ports:
- "${SERVER_PORT}:3000"
- ${SERVER_PORT}:3000
environment:
POSTGRESQL_URL: "postgres://${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}@db:5433"
BCRYPT_SALT: "${BCRYPT_SALT}"
JWT_SECRET_KEY: "${JWT_SECRET_KEY}"
JWT_EXPIRATION: "${JWT_EXPIRATION}"
BCRYPT_SALT: ${BCRYPT_SALT}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
JWT_EXPIRATION: ${JWT_EXPIRATION}
DB_URL: postgres://${DB_USER}:${DB_PASSWORD}@db:5433
depends_on:
- migrate
migrate:
Expand All @@ -22,30 +22,29 @@ services:
command: npm run db:init
working_dir: /app/server
environment:
POSTGRESQL_URL: "postgres://${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}@db:5432"
BCRYPT_SALT: "${BCRYPT_SALT}"
BCRYPT_SALT: ${BCRYPT_SALT}
DB_URL: postgres://${DB_USER}:${DB_PASSWORD}@db:5432
depends_on:
db:
condition: service_healthy
db:
image: postgres:12
ports:
- ${DB_PORT}:5432
environment:
POSTGRES_USER: ${POSTGRESQL_USER}
POSTGRES_PASSWORD: ${POSTGRESQL_PASSWORD}
ports: ${POSTGRESQL_PORT}:5432
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres:/var/lib/postgresql/data
healthcheck:
test:
[
"CMD",
"pg_isready",
"-q",
"-d",
"${POSTGRESQL_DB_NAME}",
"-U",
"${POSTGRESQL_USER}",
]
- CMD
- pg_isready
- -q
- -d
- ${DB_DB_NAME}
- -U
- ${DB_USER}
timeout: 45s
interval: 10s
retries: 10
Expand Down
Loading