Skip to content

Commit fd6d183

Browse files
committed
[Docker]: add basic example
1 parent 55c6dee commit fd6d183

20 files changed

+3378
-0
lines changed

docker/docker-example/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

docker/docker-example/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM node:20
2+
WORKDIR /app
3+
COPY . .
4+
RUN npm install
5+
EXPOSE 5173
6+
CMD ["npm", "run", "dev"]

docker/docker-example/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
container="docker-example"
2+
3+
up:
4+
docker compose up -d
5+
6+
bash:
7+
docker exec -it $(container) bash
8+
9+
stop:
10+
docker compose stop
11+
12+
rm:
13+
docker rm $(container) --force
14+
15+
rmi:
16+
docker rmi $$(docker images -q) --force
17+
18+
build:
19+
docker compose up -d --build
20+
21+
rebuild: stop rm rmi build

docker/docker-example/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Docker example
2+
3+
Grazie al makefile basta lanciare il comando `make`. Questo eseguirà `docker compose up`. A quel punto basta aprire il link http://localhost:8080.
4+
5+
```
6+
make
7+
```

docker/docker-example/compose.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
app:
3+
container_name: docker-example
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
ports:
8+
- "8080:5173"
9+
volumes:
10+
- .:/app
11+
- /app/node_modules
12+
environment:
13+
NODE_ENV: development
14+
command: npm run dev
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
7+
export default tseslint.config(
8+
{ ignores: ['dist'] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ['**/*.{ts,tsx}'],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
'react-hooks': reactHooks,
18+
'react-refresh': reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
'react-refresh/only-export-components': [
23+
'warn',
24+
{ allowConstantExport: true },
25+
],
26+
},
27+
},
28+
)

docker/docker-example/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)