Creation container pour l'API reviews

This commit is contained in:
2023-01-11 11:31:33 +01:00
parent 81dd02943a
commit b5e34fd898
21 changed files with 128 additions and 2 deletions

View File

@@ -2,11 +2,18 @@ version: "3.9"
services:
db:
image: mysql:latest
container_name: db
expose:
- 3306
volumes:
- ./db:/docker-entrypoint-initdb.d
restart: always
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot"] # Command to check health.
interval: 5s # Interval between health checks.
timeout: 5s # Timeout for each health checking.
retries: 20 # Hou many times retries.
start_period: 10s # Estimated time to boot.
environment:
MYSQL_ROOT_PASSWORD: telereview
MYSQL_DATABASE: telereview
@@ -14,10 +21,29 @@ services:
phpmyadmin:
image: phpmyadmin:latest
restart: always
container_name: phpmyadmin
depends_on:
- db
environment:
PMA_ARBITRARY: 1
PMA_HOST: db
PMA_USER: root
PMA_PASSWORD: telereview
ports:
- 8080:80
- 8000:80
reviews_api:
container_name: reviews_api
ports:
- 8080:8080
environment:
- NODE_ENV=production
- DB_USER=root
- DB_PASSWORD=telereview
- DB_HOST=db
- DB_NAME=telereview
- PORT=8080
depends_on:
db:
condition: service_healthy
build: ./reviews_api

View File

@@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

View File

@@ -0,0 +1,9 @@
FROM node:lts-alpine
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 8080
RUN chown -R node /usr/src/app
USER node
CMD ["node", "index.js"]

View File

@@ -7,7 +7,7 @@ import { startCronJobs } from './stats/update_stats.js';
import * as borneHandler from './borne/get_handler.js';
const app = express();
console.log(process.env);
app.use(bodyParser.urlencoded({extended:true}))
dotenv.config()
app.post('/add_review', (req,res) => addReviewFromRequest(req,res));

View File

@@ -0,0 +1,6 @@
while ! wget $DB_HOST:3306;
do
sleep 1
echo "Waiting for database connection..."
done
node index.js