Basic Docker and Docker Compose containerization working.
This commit is contained in:
parent
03efb5aa3d
commit
02e3b6df66
3
.gitignore
vendored
3
.gitignore
vendored
@ -35,3 +35,6 @@ out/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
# Custom
|
||||||
|
.env
|
||||||
|
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM gradle:8.8.0-jdk21 AS build
|
||||||
|
WORKDIR /mme-api
|
||||||
|
COPY . /mme-api
|
||||||
|
RUN gradle build
|
||||||
|
|
||||||
|
FROM eclipse-temurin:21
|
||||||
|
WORKDIR /mme-api
|
||||||
|
COPY --from=build /mme-api/build/libs/api-0.1.0-SNAPSHOT.jar .
|
||||||
|
COPY dev-data ./dev-data/
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD ["java", "-jar", "api-0.1.0-SNAPSHOT.jar", "--spring.profiles.active=dev"]
|
17
README.md
Normal file
17
README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Meals Made Easy API
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
First, create a `.env` file with the following environment variables:
|
||||||
|
|
||||||
|
- `MINIO_ROOT_PASSWORD=<put something here>`
|
||||||
|
- `MYSQL_ROOT_PASSWORD=<put something here>`
|
||||||
|
- `MYSQL_PASSWORD=<put something here>`
|
||||||
|
|
||||||
|
Then run `docker compose up -d --build`. The `--build` option can be omitted if you
|
||||||
|
have already built the `api` from `Dockerfile`. Once Docker Compose has finished
|
||||||
|
starting everything, navigate to `http://localhost:8080/greeting`.
|
||||||
|
You should see a simple "Hello, World!" greeting.
|
||||||
|
|
||||||
|
**N.b.: the current configuration of the app is to use the `dev` Spring-Boot profile,
|
||||||
|
which seeds the app with some simple recipes whose sources are located in the
|
||||||
|
`dev-data` directory.**
|
56
compose.yaml
Normal file
56
compose.yaml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
name: meals-made-easy-api
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mysql:latest
|
||||||
|
ports:
|
||||||
|
- '55001:3306'
|
||||||
|
- '55000:33060'
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: meals_made_easy_api
|
||||||
|
MYSQL_USER: meals-made-easy-api-user
|
||||||
|
healthcheck:
|
||||||
|
test: mysqladmin ping -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
|
||||||
|
interval: 5s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
volumes:
|
||||||
|
- mysql-data:/var/lib/mysql
|
||||||
|
minio:
|
||||||
|
image: minio/minio:latest
|
||||||
|
ports:
|
||||||
|
- 9000:9000
|
||||||
|
- 9001:9001
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
MINIO_ROOT_USER: minio-root
|
||||||
|
volumes:
|
||||||
|
- minio-data:/data
|
||||||
|
command:
|
||||||
|
- server
|
||||||
|
- /data
|
||||||
|
- --console-address
|
||||||
|
- :9001
|
||||||
|
api:
|
||||||
|
build: .
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
minio:
|
||||||
|
condition: service_started
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
MYSQL_HOST: db
|
||||||
|
MYSQL_PORT: 3306
|
||||||
|
MYSQL_DATABASE: meals_made_easy_api
|
||||||
|
MYSQL_USERNAME: meals-made-easy-api-user
|
||||||
|
MINIO_HOST: minio
|
||||||
|
MINIO_PORT: 9000
|
||||||
|
MINIO_ROOT_USER: minio-root
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
volumes:
|
||||||
|
mysql-data:
|
||||||
|
minio-data:
|
@ -1,13 +1,13 @@
|
|||||||
spring.application.name=meals-made-easy-api
|
spring.application.name=meals-made-easy-api
|
||||||
spring.jpa.hibernate.ddl-auto=create-drop
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
spring.datasource.url=jdbc:mysql://localhost:55001/meals_made_easy_api
|
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:meals_made_easy_api}
|
||||||
spring.datasource.username=meals-made-easy-api-user
|
spring.datasource.username=${MYSQL_USERNAME:meals-made-easy-api-user}
|
||||||
spring.datasource.password=devpass
|
spring.datasource.password=${MYSQL_PASSWORD}
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
app.mealsmadeeasy.api.baseUrl=http://localhost:8080
|
app.mealsmadeeasy.api.baseUrl=http://localhost:8080
|
||||||
app.mealsmadeeasy.api.security.access-token-lifetime=60
|
app.mealsmadeeasy.api.security.access-token-lifetime=60
|
||||||
app.mealsmadeeasy.api.security.refresh-token-lifetime=3600
|
app.mealsmadeeasy.api.security.refresh-token-lifetime=3600
|
||||||
app.mealsmadeeasy.api.minio.endpoint=http://localhost:9000
|
app.mealsmadeeasy.api.minio.endpoint=http://${MINIO_HOST:localhost}:${MINIO_PORT:9000}
|
||||||
app.mealsmadeeasy.api.minio.accessKey=minio-root
|
app.mealsmadeeasy.api.minio.accessKey=${MINIO_ROOT_USER}
|
||||||
app.mealsmadeeasy.api.minio.secretKey=test0123
|
app.mealsmadeeasy.api.minio.secretKey=${MINIO_ROOT_PASSWORD}
|
||||||
app.mealsmadeeasy.api.images.bucketName=images
|
app.mealsmadeeasy.api.images.bucketName=images
|
Loading…
Reference in New Issue
Block a user