71 lines
2.5 KiB
Markdown
71 lines
2.5 KiB
Markdown
# Docker build & deploy for studio-panel
|
|
|
|
This file explains how to build the `studio-panel` Docker image locally and produce a deployable artifact.
|
|
|
|
Prerequisites
|
|
- Docker installed and running on the host.
|
|
- Node.js and npm (for local build path if you prefer building before docker). If you use Docker multi-stage, Node is not needed locally.
|
|
|
|
Quick build steps (preferred: multi-stage Docker build)
|
|
|
|
From repo root or inside `packages/studio-panel`:
|
|
|
|
```bash
|
|
# from repo root
|
|
cd packages/studio-panel
|
|
# build docker (multi-stage uses npm inside builder stage)
|
|
docker build -t avanzacast/studio-panel:latest .
|
|
|
|
# run locally to test
|
|
docker run --rm -it -p 3020:80 avanzacast/studio-panel:latest
|
|
|
|
# now test with curl
|
|
curl -I http://localhost:3020/
|
|
```
|
|
|
|
Notes
|
|
- The Dockerfile is multi-stage: the builder stage runs `npm ci` and `npm run build` inside the container. The built `dist/` is copied to nginx in the final image.
|
|
- The Dockerfile copies the entire monorepo into the builder context to allow `file:../avanza-ui` dependency to be resolved during container build.
|
|
|
|
If the build fails inside Docker due to strict network or registry errors, you can build locally first and then use a simpler Dockerfile that only copies the `dist/` folder into the nginx image:
|
|
|
|
Local-build alternative:
|
|
|
|
```bash
|
|
# build locally
|
|
cd packages/studio-panel
|
|
npm ci
|
|
npm run build
|
|
|
|
# create a simple nginx image
|
|
cd packages/studio-panel
|
|
cat > Dockerfile.simple <<'EOF'
|
|
FROM nginx:stable-alpine
|
|
COPY dist /usr/share/nginx/html
|
|
COPY deploy/nginx.avanzacast.conf /etc/nginx/conf.d/default.conf
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
EOF
|
|
|
|
docker build -f Dockerfile.simple -t avanzacast/studio-panel:local .
|
|
```
|
|
|
|
If you want the tarball artifact to deploy on the server, run:
|
|
|
|
```bash
|
|
# after successful build and image creation
|
|
IMAGE=avanzacast/studio-panel:latest
|
|
docker save $IMAGE -o /tmp/studio-panel-image-$(date +%s).tar
|
|
# scp that tar to the server and on server run:
|
|
# docker load -i studio-panel-image-<ts>.tar
|
|
# docker run -d --name studio-panel -p 80:80 avanzacast/studio-panel:latest
|
|
```
|
|
|
|
Troubleshooting
|
|
- If the multi-stage build cannot resolve `file:../avanza-ui`, ensure the entire repository is in the build context (we copy `..` into the builder in the current Dockerfile). If your Docker setup restricts context size, prefer local build + `Dockerfile.simple`.
|
|
- Inspect build logs with:
|
|
- `docker build --progress=plain -t avanzacast/studio-panel:local .`
|
|
- `docker logs <container>` for runtime errors.
|
|
|
|
|