Skip to content

Commit

Permalink
Merge pull request #34 from freedomofpress/11ty
Browse files Browse the repository at this point in the history
Make an initial attempt at an 11ty powered dangerzone.rocks
  • Loading branch information
apyrgio authored Aug 8, 2024
2 parents 4a722d4 + fbe9fee commit ecef813
Show file tree
Hide file tree
Showing 27 changed files with 2,767 additions and 295 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/dist/
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,18 @@

This is a static website, currently hosted at https://dangerzone.rocks/

You can edit it locally and test it in your browser without the use of a
webserver or a static site generator.
We use the static site generator [Eleventy](https://www.11ty.dev/) to build the site.

To run Eleventy directly, you need Node.js (an LTS release or later). Run `npm install` to
install the dependencies, then run `npm run serve` to serve the site on port 8080.

In production, we use a containerized setup. You can also use it to serve the site:

To test the deploy container:

```sh
docker build -t dzr -f deploy/Dockerfile .
docker run --rm -p 127.0.0.1:8080:5080 dzr
```

This will also serve the site on port 8080.
138 changes: 0 additions & 138 deletions about.html

This file was deleted.

13 changes: 11 additions & 2 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# sha256 as of 2024-03-15
FROM node:21.7.1-alpine3.19@sha256:4999fa1391e09259e71845d3d0e9ddfe5f51ab30253c8b490c633f710c7446a0 AS eleventy-build

WORKDIR /usr/src/page
COPY package.json package-lock.json eleventy.config.js ./
COPY src ./src
RUN npm ci
RUN npm run build

# sha256 as of 2023-07-05
FROM nginx:mainline-alpine@sha256:2d4efe74ef541248b0a70838c557de04509d1115dec6bfc21ad0d66e41574a8a

COPY deploy/nginx.conf /etc/nginx
RUN mkdir -p /opt/nginx/run /opt/nginx/webroot/assets && chown -R nginx:nginx /opt/nginx

USER nginx
COPY --chown=nginx:nginx index.html about.html favicon.ico /opt/nginx/webroot/
COPY --chown=nginx:nginx assets/ /opt/nginx/webroot/assets/
COPY --from=eleventy-build --chown=nginx:nginx /usr/src/page/dist /opt/nginx/webroot/
EXPOSE 5080
3 changes: 2 additions & 1 deletion deploy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ http {
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "same-origin" always;
add_header Referrer-Policy "strict-origin" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
}
}
16 changes: 16 additions & 0 deletions eleventy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets")
eleventyConfig.addPassthroughCopy("src/favicon.ico")

eleventyConfig.addCollection("posts", function(collection) {
return collection.getFilteredByGlob("src/posts/*.md");
})

return {
dir: {
input: "src",
output: "dist",
includes: '_layouts',
}
}
}
Loading

0 comments on commit ecef813

Please sign in to comment.