Skip to content

Commit 412047c

Browse files
authored
Merge pull request #18 from acemilyalcin/fix-dockerfile
Fixed Dockerfile and docker-compose.yml
2 parents 1967eb5 + d9b4eb2 commit 412047c

6 files changed

Lines changed: 32 additions & 22 deletions

File tree

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
npm-debug.log
3+
Dockerfile
4+
.dockerignore
5+
.git
6+
.gitignore
7+
docker-compose.yml

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:24-alpine
2+
3+
# Create app user and group
4+
RUN addgroup app && adduser -S -G app app
5+
6+
WORKDIR /usr/src/app
7+
8+
# Copy package files and install dependencies as root
9+
COPY package*.json ./
10+
RUN npm ci --omit=dev
11+
12+
# Copy rest of the app
13+
COPY . .
14+
15+
# Switch to non-root user for runtime
16+
USER app
17+
18+
EXPOSE 3000
19+
CMD ["node", "app.js"]

app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var express = require('express');
99

1010
var app = express();
1111

12-
app.set('port', process.env.PORT || 3005); // GİRİŞ PORTU AYARLANDI
12+
app.set('port', process.env.PORT || 3000); // GİRİŞ PORTU AYARLANDI
1313
app.set('views', __dirname + '/app/server/views'); // VIEW KLASÖRÜ TANITILDI
1414
app.set('view engine', 'ejs'); // VIEW ENGINE AYARLANDI
1515
app.use(express.static(__dirname + '/app/public')); // KULLANICILAR TARAFINDAN ERİŞİLEBİLEN KLASÖR TANIMLANDI

docker-compose.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
version: '3.7'
2-
31
services:
4-
environment:
5-
container_name: environment
2+
app:
3+
container_name: app
64
build:
75
context: .
8-
dockerfile: dockerfile
6+
dockerfile: Dockerfile
97
ports:
10-
- 3005:3005
11-
stdin_open: true
12-
environment:
13-
- CHOKIDAR_USEPOLLING=true
14-
command: node app.js
8+
- "3000:3000"

dockerfile

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"description": "Sample Node.js Project",
55
"main": "app.js",
66
"scripts": {
7-
"start": "node app.js",
8-
"test": "echo \"Error: no test specified\" && exit 1",
9-
"build": "echo 'Building the project...' && exit 0" // Replace this with your actual build command
7+
"start": "node app.js"
108
},
119
"author": "Adem Cemil YALCIN",
1210
"license": "ISC",

0 commit comments

Comments
 (0)