Skip to content

Commit ca0cebb

Browse files
authored
πŸ§‘β€πŸ’» Add dev container (#447)
1 parent 175f6bb commit ca0cebb

File tree

9 files changed

+78
-5
lines changed

9 files changed

+78
-5
lines changed

β€Ž.changeset/calm-zoos-bow.mdβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"socialify": patch
3+
---
4+
5+
Set up dev container

β€Ž.devcontainer/Dockerfileβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG VARIANT="22-bookworm"
2+
3+
FROM mcr.microsoft.com/devcontainers/typescript-node:1-${VARIANT}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "Socialify Dev Environment",
3+
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
8+
"features": {
9+
"ghcr.io/devcontainers/features/github-cli:1": {
10+
"installDirectlyFromGitHubRelease": true,
11+
"version": "latest"
12+
}
13+
},
14+
15+
"forwardPorts": [3000],
16+
17+
"containerEnv": {
18+
"NEXT_TELEMETRY_DISABLED": "1",
19+
"PNPM_HOME": "/home/node/.local/share/pnpm",
20+
"PNPM_STORE_DIR": "/home/node/.local/share/.pnpm-store"
21+
},
22+
23+
"postCreateCommand": "corepack install",
24+
25+
"postStartCommand": ".devcontainer/post-start.sh",
26+
27+
"customizations": {
28+
"vscode": {
29+
"extensions": [
30+
"GitHub.copilot",
31+
"biomejs.biome",
32+
"ms-playwright.playwright"
33+
]
34+
}
35+
}
36+
}

β€Ž.devcontainer/post-start.shβ€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if [ ! -f /home/node/.first_run ]; then
4+
git config --global --add safe.directory $(pwd)
5+
git config --global core.autocrlf true
6+
git config --global core.editor nano
7+
8+
pnpm config set store-dir $PNPM_STORE_DIR
9+
pnpm install
10+
pnpm playwright:install
11+
12+
if [ ! -f .env ]; then
13+
cp .env.example .env
14+
echo -e "\e[31mPlease fill in the .env file\e[0m"
15+
fi
16+
17+
touch /home/node/.first_run
18+
fi

β€Ž.gitignoreβ€Ž

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3-
# Local vscode
4-
.vscode
5-
63
# Playwright
74
/.playwright/.cache
85
/.playwright/test-report

β€Ž.husky/prepare-commit-msgβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
# gitmoji as a commit hook
33
exec < /dev/tty
4-
npx gitmoji-cli --hook $1 $2
4+
npx --yes gitmoji-cli --hook $1 $2

β€Ž.vscode/settings.jsonβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.defaultFormatter": "biomejs.biome",
3+
"editor.formatOnSave": true,
4+
"editor.tabSize": 2,
5+
"files.insertFinalNewline": true
6+
}

β€ŽREADME.mdβ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,18 @@ pnpm dev
7878

7979
### Testing and Committing
8080

81+
[![Open in Dev Container](https://img.shields.io/static/v1?label=Dev%20Containers&message=Click%20to%20Launch&color=blue)](https://open.vscode.dev/wei/socialify)
82+
83+
If you already have VS Code and Docker installed locally, you can also click [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/wei/socialify) to get started. Clicking this link will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
84+
8185
Socialify uses [`biomejs`](https://biomejs.dev/) as linter/formatter, [`Jest`](https://jestjs.io/) for unit testing, and [`Playwright`](https://playwright.dev/) for end-to-end testing.
8286

8387
Make sure to run and pass the linter, unit and end-to-end tests locally before committing your code. Please let us know in case you need to update the test snapshots. More in `"scripts"` section in your `package.json` file.
8488

8589
```shell
90+
# Required: Set environment variables in .env.
91+
cp .env.example .env
92+
8693
# Run linter/formatter
8794
pnpm lint
8895

@@ -93,7 +100,7 @@ pnpm lint
93100
pnpm test:unit
94101

95102
# Install Playwright dependencies (first-time)
96-
# pnpm playwright install --with-deps chrome
103+
# pnpm playwright:install
97104

98105
# Run e2e tests
99106
pnpm test:e2e

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"ncu": "npx npm-check-updates -u",
2323
"verify": "pnpm lint && pnpm test && pnpm build",
2424
"download-font": "./fonts/download-font.sh",
25+
"playwright:install": "pnpm playwright install --with-deps chromium",
2526
"postinstall": "mkdir -p ./public && cp ./node_modules/yoga-wasm-web/dist/yoga.wasm ./public/yoga.wasm && cp ./node_modules/@resvg/resvg-wasm/index_bg.wasm ./public/resvg_bg.wasm",
2627
"prepare": "is-ci || husky"
2728
},

0 commit comments

Comments
Β (0)