Skip to content

Commit

Permalink
update release drafter install command, move compose.yaml to deploy/d…
Browse files Browse the repository at this point in the history
…ocker-compose, create deploy/docker-compose.env to allow image overriding
  • Loading branch information
paul-gilber committed Oct 31, 2023
1 parent 3bd83ec commit ca2dfd0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ template: |
## Install from the command line
```sh
docker pull ghcr.io/$OWNER/$REPOSITORY:v$RESOLVED_VERSION
DEMOAPP_BACKEND_IMAGE="ghcr.io/$OWNER/$REPOSITORY:v$RESOLVED_VERSION" docker compose --project-directory deploy/docker-compose u
```
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ services:
- "8080:8080" # Forwards container port 8080 to host port 8080. URL: http://localhost:8080/. Actuator URL: http://localhost:8080/actuator/health
```
```sh
docker-compose up # builds application image when it doesn't exist
docker-compose up --build # rebuild application image
docker-compose down # remove containers, networks and volumes created by docker compose
# Note: by default, compose.yaml was configured to use an existing application image. Run build before docker compose or update compose.yaml and enable `build` field

docker compose --project-directory deploy/docker-compose up
docker compose --project-directory deploy/docker-compose up --build # rebuild application image, only applicable if `build` field is enabled
docker compose --project-directory deploy/docker-compose down # remove containers, networks and volumes created by docker compose

# Note: by default, compose.yaml was configured to use an existing application image. Run build before docker-compose or update compose.yaml and enable `build` field
```

## Testing Application Container Image with Container Structure Tests
Expand Down
6 changes: 6 additions & 0 deletions deploy/docker-compose/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DEMOAPP_BACKEND_IMAGE="demoapp-backend:latest" # locally built image
MYSQL_IMAGE="mysql:8.0" # https://hub.docker.com/_/mysql
MYSQL_ROOT_PASSWORD="local"
MYSQL_DATABASE="demoapp"
MYSQL_USER="user"
MYSQL_PASSWORD="password"
14 changes: 7 additions & 7 deletions compose.yaml → deploy/docker-compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Service top-level element reference: https://docs.docker.com/compose/compose-file/05-services/
services:
mysql: # Service name is also used as hostname when connecting from other containers
image: mysql:8.0 # https://hub.docker.com/_/mysql
image: ${MYSQL_IMAGE} # use image specified in .env file
# Docker Hub mysql image already exposes port 3306, thus `expose` keyword can be omitted
# expose:
# - "3306"
environment:
MYSQL_ROOT_PASSWORD: local
MYSQL_DATABASE: demoapp
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
healthcheck:
# Login to mysql demoapp db
test: mysql --host=localhost --user=root --password=$$MYSQL_ROOT_PASSWORD demoapp # command for testing health
Expand All @@ -31,15 +31,15 @@ services:
depends_on:
mysql:
condition: service_healthy # healthy status is indicated by `healthcheck` keyword
image: demoapp-backend:latest # use built image
image: ${DEMOAPP_BACKEND_IMAGE} # use image specified in .env file
# Build image from Containerfile
# build:
# context: .
# dockerfile: Containerfile.multistage
environment:
# Externalized Spring Configuration: https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/boot-features-external-config.html
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: local
SPRING_DATASOURCE_PASSWORD: ${MYSQL_ROOT_PASSWORD}
healthcheck:
# Check Spring Boot Actuator
test: curl --fail http://localhost:8080/actuator/health # command for testing health
Expand Down

0 comments on commit ca2dfd0

Please sign in to comment.