feat: implement automated Docker deployment and update README
- Replaced manual rsync/npm_deploy workflow with multi-stage Docker builds. - Added Dockerfile and .dockerignore for staging and production environments. - Added 'deploy:staging' and 'deploy:prod' scripts to package.json. - Updated README.md with new deployment instructions.
This commit is contained in:
40
README.md
40
README.md
@@ -123,36 +123,34 @@ Developer sandbox pages — not for production use.
|
||||
|
||||
# How to build and deploy SvelteKit:
|
||||
|
||||
Copy the contents of the "build" directory to ./npm_deploy/build/
|
||||
The deployment is now fully automated using Docker Compose. The application is built directly from source inside a clean Docker environment, eliminating the need for manual `rsync` or `npm_deploy` management.
|
||||
|
||||
### Commands
|
||||
|
||||
Run these commands from the root of the `aether_app_sveltekit` project:
|
||||
|
||||
#### 1. Deploy to Staging (Dev)
|
||||
This builds and restarts the staging containers (`ae_app_node_dev`, etc.) on your local workstation.
|
||||
```bash
|
||||
npm run build
|
||||
npm run deploy:staging
|
||||
```
|
||||
|
||||
If this is just a quick build update then only the build directory needs to be copied (rsync).
|
||||
|
||||
#### 2. Deploy to Production
|
||||
This builds the image using production flags and restarts the production containers.
|
||||
```bash
|
||||
rsync -vhrz --exclude 'node_modules' ~/OSIT_dev/aether_app_sveltekit/build/ ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ --delete
|
||||
|
||||
rsync -vhrz ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ scott@linode.oneskyit.com:/srv/env/prod_aether_sveltekit/npm_deploy/build/ --delete
|
||||
npm run deploy:prod
|
||||
```
|
||||
|
||||
If this includes package updates (not development) we need to copy the new package.json. Manually copy the new package.json file to ./npm_deploy/. This also needs to be copied to the server. Copy the package.json even though not really used.
|
||||
### Technical Details
|
||||
|
||||
Run the --omit dev to clear out the node_modules directory. Copy the root node_modules directory to ./npm_deploy/build/node_modules/ after running te omit dev command.
|
||||
- **Dockerfile**: Uses a multi-stage build. Stage 1 (builder) installs dependencies and builds the app using the `BUILD_MODE` argument. Stage 2 (runtime) creates the final lightweight image.
|
||||
- **Environment Handling**:
|
||||
- `PUBLIC_` variables are baked into the image during the build step based on `.env.staging` or `.env.prod`.
|
||||
- Private runtime variables are passed via the `env_file` in `docker-compose.yml`.
|
||||
- **Networking**: Containers are automatically joined to the `ae_dev_net` network to allow local Nginx proxying.
|
||||
- **Legacy Migration**: The `upstream` in the local Nginx configuration has been updated to point to these new SvelteKit containers on port 3000.
|
||||
|
||||
```bash
|
||||
npm ci --omit dev
|
||||
|
||||
# copy/paste, rsync, or cp
|
||||
rsync -vhrz ~/OSIT_dev/aether_app_sveltekit/node_modules ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ --delete
|
||||
|
||||
# copy package.json as well
|
||||
|
||||
npm install
|
||||
```
|
||||
|
||||
Everything should be ready to run on the development server and production server.
|
||||
---
|
||||
|
||||
# Rebuild the node_modules directory and manually install extra Svelte packages
|
||||
|
||||
|
||||
Reference in New Issue
Block a user