mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 10:30:17 +01:00
Creation container pour l'API reviews
This commit is contained in:
@@ -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
|
||||
24
code/reviews_api/.dockerignore
Normal file
24
code/reviews_api/.dockerignore
Normal 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
|
||||
9
code/reviews_api/Dockerfile
Normal file
9
code/reviews_api/Dockerfile
Normal 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"]
|
||||
@@ -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));
|
||||
6
code/reviews_api/wait_mysql.sh
Normal file
6
code/reviews_api/wait_mysql.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
while ! wget $DB_HOST:3306;
|
||||
do
|
||||
sleep 1
|
||||
echo "Waiting for database connection..."
|
||||
done
|
||||
node index.js
|
||||
Reference in New Issue
Block a user