diff --git a/.gitignore b/.gitignore index 16d54bb..bfd6a29 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ dist/ # dependencies node_modules/ +# Podman / Compose +.env.podman + # logs npm-debug.log* yarn-debug.log* diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..5c72c1d --- /dev/null +++ b/Containerfile @@ -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"] diff --git a/README.md b/README.md index 35a8a56..c7d79cc 100644 --- a/README.md +++ b/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 astro ...` | Run CLI commands like `astro add`, `astro check` | | `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`. diff --git a/astro.config.mjs b/astro.config.mjs index 80c27f2..87c4c0f 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,6 +5,6 @@ import preact from "@astrojs/preact"; // https://astro.build/config export default defineConfig({ - site: "https://example.com", + site: "https://blog.n-daisuke897.com/", integrations: [preact()] }); \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..eed04fc --- /dev/null +++ b/compose.yml @@ -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: