This commit is contained in:
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Build stage
|
||||||
|
FROM node:18-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Artifacts stage (per estrarre i build artifacts)
|
||||||
|
FROM build AS artifacts
|
||||||
|
RUN mkdir -p /out/dist && cp -r dist/* /out/dist/
|
||||||
|
|
||||||
|
# Production stage
|
||||||
|
FROM node:18-alpine AS production
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
COPY --from=build /app/package*.json ./
|
||||||
|
RUN npm install --production
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["node", "dist/index.js"]
|
||||||
7
package.json
Normal file
7
package.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "demo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"build": "mkdir -p dist && cp src/index.js dist/"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/index.js
Normal file
20
src/index.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
const server = http.createServer((req, res) => {
|
||||||
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||||
|
res.end('Hello from Gitea CI/CD!\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(3000, () => {
|
||||||
|
console.log('Server running on port 3000');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
**Struttura del repo:**
|
||||||
|
```
|
||||||
|
demo/
|
||||||
|
├── Dockerfile
|
||||||
|
├── package.json
|
||||||
|
├── README.md
|
||||||
|
└── src/
|
||||||
|
└── index.js
|
||||||
Reference in New Issue
Block a user