feat(dev): add Podman-based container workflow
- Add Containerfile for running Astro dev server in a container - Add compose.yml (slirp4netns) for WSL2/rootless compatibility - Document Podman compose usage and troubleshooting steps in README - Ignore optional Podman env file in .gitignore
This commit is contained in:
parent
f6c3aff100
commit
cf76a69948
5 changed files with 66 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -6,6 +6,9 @@ dist/
|
||||||
# dependencies
|
# dependencies
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
|
# Podman / Compose
|
||||||
|
.env.podman
|
||||||
|
|
||||||
# logs
|
# logs
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
|
|
|
||||||
15
Containerfile
Normal file
15
Containerfile
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM node:lts-bookworm-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install dependencies first (better layer caching)
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copy the rest of the project
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 4321
|
||||||
|
|
||||||
|
CMD ["npm","run","dev","--","--host","0.0.0.0","--port","4321"]
|
||||||
31
README.md
31
README.md
|
|
@ -14,3 +14,34 @@ All commands are run from the root of the project, from a terminal:
|
||||||
| `npm run preview` | Preview your build locally, before deploying |
|
| `npm run preview` | Preview your build locally, before deploying |
|
||||||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
||||||
| `npm run astro -- --help` | Get help using the Astro CLI |
|
| `npm run astro -- --help` | Get help using the Astro CLI |
|
||||||
|
|
||||||
|
## Podman (container) development
|
||||||
|
|
||||||
|
This repo can be developed inside a Podman container to keep your host clean and improve reproducibility.
|
||||||
|
|
||||||
|
### Using podman compose
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
|
On WSL2/rootless Podman, if you hit netavark/nftables errors, this repo defaults to `slirp4netns` via `network_mode` in `compose.yml`.
|
||||||
|
|
||||||
|
Then open: http://localhost:4321
|
||||||
|
|
||||||
|
Run other commands in the running container:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
podman compose exec app npm run build
|
||||||
|
podman compose exec app npm run preview -- --host 0.0.0.0 --port 4321
|
||||||
|
```
|
||||||
|
|
||||||
|
### Troubleshooting (WSL2)
|
||||||
|
|
||||||
|
If hot reload is unstable/slow, enable polling:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
CHOKIDAR_USEPOLLING=1 podman compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
|
Tip: placing the repo under the WSL filesystem (e.g. `~/project/...`) is often faster than under `/mnt/c`.
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@ import preact from "@astrojs/preact";
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: "https://example.com",
|
site: "https://blog.n-daisuke897.com/",
|
||||||
integrations: [preact()]
|
integrations: [preact()]
|
||||||
});
|
});
|
||||||
16
compose.yml
Normal file
16
compose.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Containerfile
|
||||||
|
# WSL2/rootless: avoid netavark+nftables bridge rules by using slirp4netns
|
||||||
|
network_mode: "slirp4netns:allow_host_loopback=true"
|
||||||
|
ports:
|
||||||
|
- "4321:4321"
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- node_modules:/app/node_modules
|
||||||
|
command: npm run dev -- --host 0.0.0.0 --port 4321
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
node_modules:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue