Skip to content

Commit

Permalink
example done
Browse files Browse the repository at this point in the history
  • Loading branch information
ardnaxelas committed Sep 24, 2024
1 parent a34d67e commit 536b9c3
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
13 changes: 13 additions & 0 deletions citywalls/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:18

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD [ "npm", "start" ]
File renamed without changes.
25 changes: 25 additions & 0 deletions citywalls/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express = require('express');
const { Database } = require('arangojs');

const app = express();
const port = 3000;

const db = new Database({
url: 'http://arango:8529', // то имя сервиса в docker-compose
auth: { username: 'root', password: 'password' }
});

// Маршрут для проверки базы данных и вывода "Hello World"
app.get('/', async (req, res) => {
try {
await db.version();
res.send('Hello World');
} catch (err) {
console.error('Ошибка подключения к базе данных:', err);
res.status(500).send('Не удалось подключиться к базе данных');
}
});

app.listen(port, () => {
console.log(`Сервер запущен на порту ${port}`);
});
25 changes: 25 additions & 0 deletions citywalls/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.8'

services:
arango:
image: arangodb:latest
environment:
- ARANGO_ROOT_PASSWORD=password
ports:
- "8529:8529"
volumes:
- arango_data:/var/lib/arangodb3

nodeapp:
build: .
depends_on:
- arango
ports:
- "3000:3000"
environment:
- NODE_ENV=production
volumes:
- .:/usr/src/app

volumes:
arango_data:
16 changes: 16 additions & 0 deletions citywalls/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "arango-hello-world",
"version": "1.0.0",
"description": "проверка работы ArangoDB",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"arangojs": "^9.0.0",
"express": "^4.21.0"
},
"keywords": [],
"author": "",
"license": "ISC"
}

0 comments on commit 536b9c3

Please sign in to comment.