Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New repo structure #1488

Merged
merged 14 commits into from
Apr 4, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"editor.formatOnSave": true,
"eslint.workingDirectories": ["./new-admin", "./new-client"]
"eslint.workingDirectories": [
"./apps/admin",
"./apps/client",
"./apps/backend"
]
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- This release marks the removal of the legacy V1 API (`/api/v1`) in both the NodeJS backend and the old .NET 4.5 backend (refer to the _Removed_ section below). Client UI is now V2-compatible only, as it requires the consolidated loading method. This means that you may need to update your configuration. Refer to `docs/migrate-to-v2-api.md` for details.
- This release marks deprecation of some plugins that either became replaced by a new solution or transformed into a community plugin. Refer to `docs/deprecated-plugins.md` for details.
- Although not exactly a _breaking_ change, but it fits well here: **the repo has been restructured**. All apps can now be found in the `apps/` directory. The `new-` prefix has been removed from apps' names. Some shell scripts now live in `scripts/` while the majority of Docker-related files, except for the official Dockerfile, have been moved into the `Docker/` directory. PR: [#1488](https://github.com/hajkmap/Hajk/pull/1488)

### Added

Expand All @@ -33,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security

- Bumped dependencies in Client.
- The official Dockerfile build on an image based on current Node LTS (v20).

### Removed

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- Latest Git
- Visual Studio (only for the optional .NET backend)

The Client UI (`new-client`), Admin UI (`new-admin`) and NodeJS backend (`new-backend`) applications can be built and deployed on any OS supported by recent Git and Node versions (tested on macOS, Windows and Linux).
All apps reside inside the `apps/` directory. The Client UI (`client`), Admin UI (`admin`) and NodeJS backend (`backend`) applications can be built and deployed on any OS supported by recent Git and Node versions (tested on macOS, Windows and Linux).

The .NET backend (`backend-dotnet`) component, requires Visual Studio for Windows.

Expand Down Expand Up @@ -54,6 +54,6 @@ Hajk uses **ESLint** and **Prettier** to enforce code formatting across the proj

🔥 **Code that gets checked in must follow those rules.** 🔥

The `new-client` and `new-backend` directories contains all necessary configuration files. The recommended way is to use an editor that has extensions for ESLint and Prettier installed. It is also highly recommended to make the editor run Prettier on each file save (i.e. in VSCode it can be controlled by the `formatOnSave: true` flag).
The `client` and `backend` directories contain all necessary configuration files. The recommended way is to use an editor that has extensions for ESLint and Prettier installed. It is also highly recommended to make the editor run Prettier on each file save (i.e. in VSCode it can be controlled by the `formatOnSave: true` flag).

**For a simple guide on setting up VSCode with ESLint, Prettier and some , see [this presentation](dokumentation/VSCodeSetup.pdf)**. (Swedish only)
6 changes: 3 additions & 3 deletions Docker/Dockerfile.hajk-simple.ubi8
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Build the client
FROM registry.redhat.io/rhel9/nodejs-18 as clientBuilder
COPY /new-client/package*.json ./
FROM registry.redhat.io/rhel9/nodejs-20 as clientBuilder
COPY /apps/client/package*.json ./
USER root
RUN npm install
COPY ./new-client .
COPY ./apps/client .
RUN npm run build --ignore-scripts

FROM registry.access.redhat.com/ubi8/nginx-122
Expand Down
20 changes: 10 additions & 10 deletions Docker/Dockerfile.rhel9-nodejs18
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# Stage 1 - Building the backend
FROM registry.redhat.io/rhel9/nodejs-18 as backendBuilder
COPY /new-backend/package*.json ./
COPY /apps/backend/package*.json ./
USER root
#RUN npm install npm@latest -g
RUN npm install
COPY ./new-backend .
COPY ./apps/backend .
RUN npm run compile

# Stage 2 - Building the client
FROM registry.redhat.io/rhel9/nodejs-18 as clientBuilder
COPY /new-client/package*.json ./
COPY /apps/client/package*.json ./
USER root
#RUN npm install npm@latest -g
RUN npm install
COPY ./new-client .
COPY ./apps/client .
RUN rm ./public/appConfig.json
RUN mv ./public/appConfig.docker.json ./public/appConfig.json
RUN npm run build --ignore-scripts

# Stage 3 - Building the admin
FROM registry.redhat.io/rhel9/nodejs-18 as adminBuilder
COPY /new-admin/package*.json ./
COPY /apps/admin/package*.json ./
USER root
#RUN npm install npm@latest -g
RUN npm install
COPY ./new-admin .
COPY ./apps/admin .
RUN rm ./public/config.json
RUN mv ./public/config.docker.json ./public/config.json
RUN npm run build --ignore-scripts

# Stage 4 - Combine everything and fire it up
FROM registry.redhat.io/rhel9/nodejs-18-minimal
COPY /new-backend/package*.json ./
COPY /apps/backend/package*.json ./
USER root
#RUN npm install npm@latest -g
RUN npm install --production
USER 1001
COPY --from=backendBuilder /opt/app-root/src/dist ./
COPY /new-backend/.env .
COPY /new-backend/App_Data ./App_Data_tmp
COPY /new-backend/static ./static
COPY /apps/backend/.env .
COPY /apps/backend/App_Data ./App_Data_tmp
COPY /apps/backend/static ./static
COPY --from=clientBuilder /opt/app-root/src/build ./static/client
COPY --from=adminBuilder /opt/app-root/src/build ./static/admin
USER root
Expand Down
28 changes: 14 additions & 14 deletions Docker/Dockerfile.ubi8-nodejs
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# Stage 1 - Building the backend
FROM registry.access.redhat.com/ubi8/nodejs-16 as backendBuilder
COPY /new-backend/package*.json ./
FROM registry.access.redhat.com/ubi8/node-20 as backendBuilder
COPY /apps/backend/package*.json ./
USER root
RUN npm install
COPY ./new-backend .
COPY ./apps/backend .
RUN npm run compile

# Stage 2 - Building the client
FROM registry.access.redhat.com/ubi8/nodejs-16 as clientBuilder
COPY /new-client/package*.json ./
FROM registry.access.redhat.com/ubi8/node-20 as clientBuilder
COPY /apps/client/package*.json ./
USER root
RUN npm install --ignore-scripts
COPY ./new-client .
COPY ./apps/client .
RUN rm ./public/appConfig.json
RUN mv ./public/appConfig.docker.json ./public/appConfig.json
RUN npm run build --ignore-scripts

# Stage 3 - Building the admin
FROM registry.access.redhat.com/ubi8/nodejs-16 as adminBuilder
COPY /new-admin/package*.json ./
FROM registry.access.redhat.com/ubi8/node-20 as adminBuilder
COPY /apps/admin/package*.json ./
USER root
RUN npm install
COPY ./new-admin .
COPY ./apps/admin .
RUN rm ./public/config.json
RUN mv ./public/config.docker.json ./public/config.json
RUN npm run build

# Stage 4 - Combine everything and fire it up
FROM registry.access.redhat.com/ubi8/nodejs-16-minimal
COPY /new-backend/package*.json ./
FROM registry.access.redhat.com/ubi8/node-20-minimal
COPY /apps/backend/package*.json ./
USER root
RUN npm install --production
USER 1001
COPY --from=backendBuilder /opt/app-root/src/dist ./
COPY /new-backend/.env .
COPY /new-backend/App_Data ./App_Data
COPY /new-backend/static ./static
COPY /apps/backend/.env .
COPY /apps/backend/App_Data ./App_Data
COPY /apps/backend/static ./static
COPY --from=clientBuilder /opt/app-root/src/build ./static/client
COPY --from=adminBuilder /opt/app-root/src/build ./static/admin
USER root
Expand Down
22 changes: 11 additions & 11 deletions Docker/backend-and-admin.dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Stage 1 - Building the backend
FROM node:alpine as backendBuilder
FROM node:20-alpine as backendBuilder
WORKDIR /usr/app
COPY /new-backend/package*.json ./
COPY /apps/backend/package*.json ./
RUN npm install
COPY ./new-backend .
COPY ./apps/backend .
RUN npm run compile

# Stage 2 - Building the admin
FROM node:alpine as adminBuilder
FROM node:20-alpine as adminBuilder
WORKDIR /usr/app
COPY /new-admin/package*.json ./
COPY /apps/admin/package*.json ./
RUN npm install
COPY ./new-admin .
COPY ./apps/admin .
RUN rm ./public/config.json
RUN mv ./public/config.docker.json ./public/config.json
RUN npm run build

# Stage 3 - Combine everything and fire it up
FROM node:14-alpine
FROM node:20-alpine
WORKDIR /usr/app
COPY /new-backend/package*.json ./
COPY /apps/backend/package*.json ./
RUN npm install --production
COPY --from=backendBuilder /usr/app/dist ./
COPY /new-backend/.env .
COPY /new-backend/App_Data ./App_Data
COPY /new-backend/static ./static
COPY /apps/backend/.env .
COPY /apps/backend/App_Data ./App_Data
COPY /apps/backend/static ./static
COPY --from=adminBuilder /usr/app/build ./static/admin
VOLUME /usr/app/App_Data
EXPOSE 3002
Expand Down
30 changes: 15 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:18-alpine AS buildImage
FROM node:20-alpine AS buildImage

# --- BACKEND --- #
# Start with Backend
WORKDIR /tmp/build/new-backend
COPY /new-backend ./
WORKDIR /tmp/build/backend
COPY /apps/backend ./
RUN npm ci
RUN npm run compile

Expand All @@ -16,8 +16,8 @@ COPY /.git .

# --- CLIENT --- #
# Next, Client UI
WORKDIR /tmp/build/new-client
COPY /new-client .
WORKDIR /tmp/build/client
COPY /apps/client .

# Install git, it's needed for the prebuild.js script
RUN apk update
Expand All @@ -38,8 +38,8 @@ RUN apk del git

# --- ADMIN --- #
# Next, go on with Admin UI
WORKDIR /tmp/build/new-admin
COPY /new-admin .
WORKDIR /tmp/build/admin
COPY /apps/admin .
RUN npm ci
RUN rm ./public/config.json
RUN mv ./public/config.docker.json ./public/config.json
Expand All @@ -48,26 +48,26 @@ RUN npm run build

# --- FINAL ASSEMBLY --- #
# Finally, let's assembly it all into another image
FROM node:18-alpine
FROM node:20-alpine
WORKDIR /usr/app

# Copy NPM package files from Backend
COPY /new-backend/package*.json ./
COPY /apps/backend/package*.json ./
RUN npm ci --production

# Move the built Backend into app's root at /usr/app
COPY --from=buildImage /tmp/build/new-backend/dist ./
COPY --from=buildImage /tmp/build/backend/dist ./

# Copy some more necessary files. There's a great chance that
# they'll be mounted when running anyway, but if someone forgets
# that, it's good to have them around so we get running with the defaults.
COPY /new-backend/.env .
COPY /new-backend/App_Data ./App_Data
COPY /new-backend/static ./static
COPY /apps/backend/.env .
COPY /apps/backend/App_Data ./App_Data
COPY /apps/backend/static ./static

# Move the built Client and Admin dirs into static
COPY --from=buildImage /tmp/build/new-client/build ./static/client
COPY --from=buildImage /tmp/build/new-admin/build ./static/admin
COPY --from=buildImage /tmp/build/client/build ./static/client
COPY --from=buildImage /tmp/build/admin/build ./static/admin
# --- FINAL ASSEMBLY END --- #

# Go!
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ Note: There are currently two available backends for Hajk - you need to pick onl

#### Alternative 1: NodeJS backend

1. In `hajk` repo dir, go to `new-backend` and install dependencies:
1. In `hajk` repo dir, go to `apps/backend` and install dependencies:

```
cd new-backend
cd apps/backend
npm install
```

Expand Down Expand Up @@ -85,19 +85,19 @@ See Docker [README](Docker/README.md) for more information.

Now when Backend is up and running, it's time to start the Client UI (and optionally Admin UI).

1. You must tell the Client app the location of the running Backend. The configuration is made by editing `new-client/public/appConfig.json`. Make sure that `mapserviceBase` is a valid URL to a running instance of the Backend (if you're using the NodeJS application and your Backend is running on port 3002, you should set `mapserviceBase` to `"http://localhost:3002/api/v2"`.
1. The client application resides inside `new-client`. Go there (`cd new-client`) and install the dependencies and start by typing: `npm i && npm start`.
1. You must tell the Client app the location of the running Backend. The configuration is made by editing `apps/client/public/appConfig.json`. Make sure that `mapserviceBase` is a valid URL to a running instance of the Backend (if you're using the NodeJS application and your Backend is running on port 3002, you should set `mapserviceBase` to `"http://localhost:3002/api/v2"`.
1. The client application resides inside `apps/client`. Go there (`apps/client`) and install the dependencies and start by typing: `npm i && npm start`.
1. Verify that Client is running on `http://localhost:3000`.

### Launch the (optional) Admin app

This process is similar to the Client app.

1. Set the correct URL to Backend by editing `new-admin/public/config.json`.
_Map operations have moved to mapconfig so `"url_map", "url_map_list", "url_map_create", "url_map_delete"` needs to point toward `"http://localhost:3002/api/v2/mapconfig..."`, the rest is the same as for `new-client`_
2. The admin application is located in `new-admin`. To get it running do `cd new-admin && npm i && npm start`.
1. Set the correct URL to Backend by editing `apps/admin/public/config.json`.
_Map operations have moved to mapconfig so `"url_map", "url_map_list", "url_map_create", "url_map_delete"` needs to point toward `"http://localhost:3002/api/v2/mapconfig..."`, the rest is the same as for `client/`_
2. The admin application is located in `apps/admin`. To get it running do `cd apps/admin && npm i && npm start`.
3. Verify that Admin is running on `http://localhost:3001`.

## Deploying

The provided NodeJS backend comes with a built-in, optional static files server that allows you to deploy the Client and Admin applications through the Hajk's backend application (hence leverage the optional Active Directory connection to restrict access to e.g. the Admin UI app). For details, see [this section in Backend's README](https://github.com/hajkmap/Hajk/tree/master/new-backend#deploy).
The provided NodeJS backend comes with a built-in, optional static files server that allows you to deploy the Client and Admin applications through the Hajk's backend application (hence leverage the optional Active Directory connection to restrict access to e.g. the Admin UI app). For details, see [this section in Backend's README](https://github.com/hajkmap/Hajk/tree/master/apps/backend#deploy).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading