Skip to content

Commit

Permalink
Merge pull request #257 from creativecommons/add-prettier
Browse files Browse the repository at this point in the history
Add Prettier docker container
  • Loading branch information
TimidRobot authored Apr 8, 2024
2 parents 9dcce67 + 4b5103c commit 6b74df7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ think the latter experience is easier to setup with more consistent behavior.
container and type `CTRL + C`


### Formatting with Prettier

- Format specific HTML file using prettier:
```shell
docker compose run node prettier --write docs/index.html
```
- Format all HTML using prettier:
```shell
find docs -name '*.html' -exec docker compose run node prettier --write {} +
```
- [Prettier · Opinionated Code Formatter](https://prettier.io/)


## License


Expand Down
2 changes: 1 addition & 1 deletion Dockerfile → dev/jekyll/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN gem install bundler
WORKDIR /srv/jekyll

# Install site dependencies
COPY docs/Gemfile docs/Gemfile.lock ./
COPY Gemfile Gemfile.lock ./
RUN bundle install

CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", \
Expand Down
1 change: 1 addition & 0 deletions dev/jekyll/Gemfile
1 change: 1 addition & 0 deletions dev/jekyll/Gemfile.lock
6 changes: 6 additions & 0 deletions dev/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://docs.docker.com/engine/reference/builder/

# https://hub.docker.com/_/node
FROM node:bullseye-slim

RUN npm install --global prettier
12 changes: 11 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: '2.4'
services:

jekyll:
build: .
build: dev/jekyll
container_name: jekyll-cc-resource-archive
ports:
- '4000:4000'
Expand All @@ -14,3 +14,13 @@ services:
volumes:
# https://github.com/docker/for-mac/issues/1592
- ./docs:/srv/jekyll

# Example commands using this service:
# docker compose run node prettier --write docs/index.html
node:
build: dev/node
container_name: node-cc-resource-archive
volumes:
# Mount repository to working directory
- ./:/docs
working_dir: /docs

0 comments on commit 6b74df7

Please sign in to comment.