Skip to content

feat(docker): add docker support #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- [Getting started](#getting-started)
- [Chrome](#getting-started-chrome)
- [Firefox](#getting-started-firefox)
- [With docker](#with-docker)
- [Install dependency](#install-dependency)
- [For root](#install-dependency-for-root)
- [For module](#install-dependency-for-module)
Expand Down Expand Up @@ -135,6 +136,26 @@ the build speed and development experience by using Vite and Turborepo.
`module-name` - You can find it inside each `package.json` under the key `name`, e.g. `@extension/content-script`, you
can use only `content-script` without `@extension/` prefix

## With docker
First, you will have to update the file `./.husky/pre-commit`, replace
```bash
pnpm dlx lint-staged --allow-empty
```
To
```bash
docker compose exec -T node pnpm dlx lint-staged --allow-empty
```

Then you can build your entire extension with just this command :

```bash
docker compose up
```

Depending on which browser you want to target you have a "TARGET" environment variable in ./docker-compose.yml

By default, you will build a Chrome extension, if you want a firefox extension you can just uncomment the "TARGET" variable

## How do I disable modules I'm not using?

[Read here](packages/module-manager/README.md)
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
node:
container_name: extension-boilerplate
build:
context: .
dockerfile: ./docker/Dockerfile
# Replace with your current user PID/GID if you are on linux you can know which one it is with the command "id"
user: 1000:1000
# Uncomment these lines if you want to build a firefox extension
#environment:
# TARGET: firefox
network_mode: host
volumes:
- .:/app
14 changes: 14 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:23.11.0

USER root:1000

WORKDIR /app

RUN apt update \
&& apt install -y --no-install-recommends git vim less \
&& npm install --global web-ext pnpm \
&& rm -rf /var/lib/apt/lists/*

COPY --chmod=555 docker/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
13 changes: 13 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

TARGET=${TARGET:-chrome}

pnpm install

if [[ $TARGET == 'firefox' ]]; then
exec pnpm dev:firefox "$@"
fi

exec pnpm dev "$@"
Loading