- AlmaLinux / Node 16
- React 18 with SSR / SCSS / Express.js
- Docker (via Podman) / Nginx Reverse Proxy with Static File Server
- Ansible
- Vagrant / Virtualbox / Webpack
- Eslint / Stylelint / Prettier
.idea/
- Shared settings for Intellij
.vagrant/
- Vagrant local settings. Only available after vagrant up
,
stores private key to dev machine required by Ansible
dist/
- Compiled code
node_modules/
- available after npm install
, used in local dev
provision/
- Ansible scripts to provision dev / prod
src
- React/Express source code
tools
- development helper scripts
- Use either of development environments to make changes:
Vagrant(AlmaLinux) + Bare Node + Webpack -> build prod Docker image
orVagrant(AlmaLinux) + Docker-compose + Containerized Node + Webpack -> build prod Docker image
- Build production docker image
- Push the image to Docker.io
- Docker host pulls latest image
- Clone this repo
- Install
Vagrant ^2.3.0
andVirtualbox ^6.1
, runvagrant up
in project folder and you're all set - Run
npm run express-dev
for bare setup, ordocker-compose up
for dev inside docker. Both setups work with Webpack hot reload.
- Intellij IDE has issues with remote Node environments, remote linting will not work.
To make it work ssh into vagrant machine
vagrant ssh
and runnpm install
- SSH is authenticated by key, so passwordless login should be setup on production machine before any Ansible scr are ran
- Client and Server will get out of sync with Hot Reload, no solution working out-of-box atm,
and fixing this is out of scope for this repo - Vagrant on Windows:
npm install
symlinks won't work. To make them work you need to runvagrant up
as admin - Since development host doesn't have Node or NPM installed, Husky commit hooks will not work from outside of Vagrant VM, so git should be authorized and run from inside Vagrant VM for now. Linting should be handled by CI server ideally, but it's out of scope for now.
Vagrant build and ssh into development machine
# in project folder
vagrant up
vagrant ssh
Build and run development with docker-compose
docker-compose -f dev.docker-compose.yml build
docker-compose -f dev.docker-compose.yml up
Build & run latest docker production image
docker build -t docker.io/rockitengine/web:latest -f prod.Dockerfile .
docker run -d -p 8080:8080 docker.io/rockitengine/web:latest
Build and run production locally
npm run build-all;npm run express-prod
Run development with Webpack
npm run clean;npm run express-dev
Clean /dist folder
npm run clean
Lint JS / SCSS
npm run lint-js;npm run lint-css
Login & push to Docker Hub
docker login docker.io
docker push docker.io/rockitengine/web:latest
Update container on remote host
# while in /provision/ folder
ansible-playbook -i inventory.yml update.container.prod.yml
Upload/update files on remote host
# while in /provision/ folder
ansible-playbook -i inventory.yml update.upload.static.files.yml --ask-become-pass
Update nginx config
# while in /provision/ folder
ansible-playbook -i inventory.yml update.nginx.config.yml --ask-become-pass