diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8f0fbd9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +**/node_modules +**/npm-debug.log +**/.git +**/.gitignore +README.md +**/.DS_Store +**/build +**/.docusaurus +**/.env +**/.env.* +Dockerfile +Dockerfile.dev +docker-compose.yml +.dockerignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3a509f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:20-alpine AS build + +WORKDIR /app + +COPY website/package*.json ./ +RUN npm ci + +COPY website/ ./ +RUN npm run build + +FROM nginx:alpine +COPY --from=build /app/build /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..670840f --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,11 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY website/package*.json ./ +RUN npm install + +COPY website/ ./ + +EXPOSE 3000 +CMD ["npm", "start", "--", "--host", "0.0.0.0"] diff --git a/README.md b/README.md index 4daa3ea..93030b4 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,44 @@ Repository for the AboutCode public website - based on Docusaurus. The current draft website is available at: https://aboutcode-org.github.io/www.aboutcode.org/. + +## Development + +### With Docker (Recommended) + +**Development server with hot reload:** +```bash +docker-compose up dev +``` +Access at http://localhost:3001/www.aboutcode.org/ + +**Production build:** +```bash +docker-compose up prod +``` +Access at http://localhost:8080/www.aboutcode.org/ + +### Without Docker + +Install dependencies and run: +```bash +cd website +npm install +npm start +``` +Access at http://localhost:3000/www.aboutcode.org/ + +## Building + +**Build static files:** +```bash +cd website +npm run build +``` + +**With Docker:** +```bash +docker build -t aboutcode-prod . +docker run -p 8080:80 aboutcode-prod +``` + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..642a9a6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +services: + dev: + build: + context: . + dockerfile: Dockerfile.dev + ports: + - "3001:3000" + volumes: + - ./website:/app + environment: + - NODE_ENV=development + + prod: + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:80"