I don't know why the docker-compose command fails - spring-boot

I created a docker-compose.yml file in the root path as shown below
version : "3"
services:
db:
container_name: spring-db
image: mysql
platform: linux/x86_64 # 추가된 라인
environment:
MYSQL_DATABASE: spring_db
MYSQL_USER: spring_db
MYSQL_PASSWORD: spring_pw
MYSQL_ROOT_PASSWORD: root_pw
volumes:
- ./db/data:/var/lib/mysql:rw
ports:
- "3306:3306"
restart: always
app:
container_name: spring-app
image: openjdk:11-jdk
ports:
- "8080:8080"
volumes:
- ./app:/app
working_dir: /app
command: ["./gradlew", "bootrun"]
depends_on:
- db
restart: always
After creation, when I run docker-compose up -d in the project root, mysql succeeds, but the app project returns an error.
Upgrade
Sign in
spring-app
openjdk:11-jdk
RUNNING
Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
Welcome to Gradle 7.4.1!
Here are the highlights of this release:
- Aggregated test and JaCoCo reports
- Marking additional test source directories as tests in IntelliJ
- Support for Adoptium JDKs in Java toolchains
For more details see https://docs.gradle.org/7.4.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileKotlin
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootRunMainClassName UP-TO-DATE
> Task :bootRun FAILED
4 actionable tasks: 1 executed, 3 up-to-date
​
Search…
Stick to bottom
Please check the code and errors, bootrun fails and I don't know exactly where to fix it.
I am practicing how to set up the server simply using docker-compose. I just need to open the server using docker-compose with simple api code in Spring Boot, but I am unable to proceed in the above situation.

First of all, the question arose because of my carelessness.
It occurred because the openjdk version was incorrect. When I built the app image after changing the app image to openjdk17, it worked normally. You must match the jdk image to the java version you selected when creating the spring-boot project

Related

TeamCity Agent artifacts cache issue: agent accumulates artifacts from all prev builds

I have TeamCity setup in docker-compose.yml
version: "3"
services:
server:
image: jetbrains/teamcity-server:2021.1.2
ports:
- "8112:8111"
volumes:
- ./data_dir:/data/teamcity_server/datadir
- ./log_dir:/opt/teamcity/logs
db:
image: mysql
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=111
- MYSQL_DATABASE=teamcity
teamcity-agent-1:
image: jetbrains/teamcity-agent:2021.1.2-linux-sudo
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-1
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_1
ipc: host
shm_size: 1024M
teamcity-agent-2:
image: jetbrains/teamcity-agent:2021.1.2-linux-sudo
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-2
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_2
ipc: host
shm_size: 1024M
teamcity-agent-3:
image: jetbrains/teamcity-agent:2021.1.2-linux-sudo
environment:
- SERVER_URL=http://server:8111
- AGENT_NAME=docker-agent-3
- DOCKER_IN_DOCKER=start
privileged: true
container_name: docker_agent_3
ipc: host
shm_size: 1024M
and I have E2E tests which I run in teamcity agents. As a result of tests execution they generate HTML report and in case tests are failed they generate video report as well. Everything working as expected locally without TeamCity. When I move it to TeamCity I setup to keep folder "reports" in artifacts. And I have the following behaviour in fact:
HTML reports are coming everytime updated
videos keep growing from build to build. I generate diff path with timestamp for folder name and for video names to avoid cache. If 1 test was failed and generated 1 video this video will come to artifacts of all next builds even they are passing and video folder should be empty
My question described exactly in jetbrains support in 2014
https://teamcity-support.jetbrains.com/hc/en-us/community/posts/206845765-Build-Agent-Artifacts-Cache-Cleanup
but I tried diff settings from there and there is no luck unfortunatelly
What I tried myself and what did not help:
tried to clean \system. artifacts_cache folder. Artifacts are still growing
tried to find a config for agent
in /data/teamcity_agent/conf/buildAgent.properties I place 2 new settings
teamcity.agent.filecache.publishing.disabled=true
teamcity.agent.filecache.size.limit.bytes=1
after agent restarting I see those 2 new settings in TeamCity webinterface which means that settings were applied
but behaviour is still the same. Maybe other settings should be used but I did not manage to find
what helps is pressing "Clean sources on this agent" in agent settings but press by hands it is not the way
It looks like a cache issue cause if I assign another agent accumulation starts from the beginning.
any suggestions are appeciated
Seems like I found an answer
https://www.jetbrains.com/help/teamcity/2021.1/clean-checkout.html#Automatic+Clean+Checkout
"Clean all files before build" option should be selected on the Create/Edit Build Configuration > Version Control Settings page

How to run docker in Ciricle CI orbs?

CircleCI introduces orb in 2.1, I am trying to add Circle Ci config my sample project.
But in my testing codes, I have used test containers to simplify the dependent config of my integration tests.
When committing my codes, the Circle CI running is failed.
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=mongo:4.0.10, imagePullPolicy=DefaultPullPolicy())
Caused by: java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
My Circle CI config.
version: 2.1
orbs:
maven: circleci/maven#1.0.1
codecov: codecov/codecov#1.1.0
jobs:
codecov:
machine:
image: ubuntu-1604:201903-01
steps:
- codecov/upload
workflows:
build:
jobs:
- maven/test:
command: "-q verify -Pcoverage"
- codecov:
requires:
- maven/test
Got it run myself.
The maven orb provides reusable jobs and commands, but by default, it used a JDK executor, does not provide a Docker runtime.
My solution is giving up the reusable job, and reuse some commands from the maven orb in your own jobs.
version: 2.1
orbs:
maven: circleci/maven#1.0.1
codecov: codecov/codecov#1.1.0
executors:
docker-mongo:
docker:
- image: circleci/openjdk:14-jdk-buster
- image: circleci/mongo:latest
jobs:
build:
executor: docker-mongo
steps:
- checkout
- maven/with_cache:
steps:
- run: mvn -q test verify -Pcoverage
- maven/process_test_results
- codecov/upload:
when: on_success
workflows:
build:
jobs:
- build

gradle docker - how to skip build if build was done previously

I noticed the gradle:5.6.3-jdk8 always build the jar when I docker-compose up the yml file.
i thought the process will skip it if build completed earlier.
how to skip build if build was done previously?
Docker compose file
locationcommand:
networks:
- abc
build:
context: ../../
dockerfile: ./test-command/Dockerfile-test
ports:
- "8008:8008"
hostname: testcommand
container_name: testcommand
Dockerfile-test
FROM gradle:5.6.3-jdk8 as builder
COPY . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle build

Jenkins doesn't notify after running docker compose up

I am using Jenkins to run my unit tests. Also, I am using docker-compose to link the spring boot and its Postgres database. Each time the Jenkins file is executed during a pull request or commit, I use the compose stack and to check that the tests have been performed correctly.
If the test fails then container aborted and Jenkins notifies but in a positive scenario when the spring boot application starts Jenkins doesn't notify and sticks.
this is the docker file :
FROM openjdk:10-jdk
COPY run.sh /
RUN chmod +x /run.sh
COPY ./target/*.jar /app.jar
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
This is the docker-compose file:
version: '3.2'
services:
app:
restart: always
build: .
container_name: app
working_dir: /app
volumes:
- .:/app
ports:
- 8085:8080
links:
- pgsql
depends_on:
- pgsql
pgsql:
image: postgres:10
container_name: pgsql
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=passwordorsomething
- POSTGRES_USER=postgres
- POSTGRES_DB=pgsql
restart: always
This is the stage for running docker compose and start spring boot and run the test :
stage('Test') {
agent {
label "docker"
}
steps {
sh 'docker rm -f $(docker ps -a -q)'
sh 'docker-compose up --build --exit-code-from app'
}
}
After Jenkins reach to 'docker-compose up --build --exit-code-from app' and the spring boot starts it sticks in the Test stage.
It's only a guess, but is the restart: always making the container restart. Assuming some of your tests are failing?
Its a good idea to add a post block to do docker-compose down to avoid zombie container

continuous integration with drone and github: build is not triggering on commit

I'm using open source edition of drone.
docker-compose.yml:
version: '2'
services:
drone-server:
image: drone/drone:0.5
ports:
- 80:8000
volumes:
- ./drone:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_ADMIN=khataev
- DRONE_GITHUB_CLIENT=github-client-string
- DRONE_GITHUB_SECRET=github-secret-string
- DRONE_SECRET=drone-secret-string
drone-agent:
image: drone/drone:0.5
command: agent
restart: always
depends_on: [ drone-server ]
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_SERVER=ws://drone-server:8000/ws/broker
- DRONE_SECRET=drone-secret-string
Application is registered and authorized on Github and secret/client strings are provided.
I placed .drone.yml file into my project repository:
pipeline:
build:
image: rails-qna
commands:
- bundle exec rake db:drop
- bundle exec rake db:create
- bundle exec rake db:migrate
- bundle exec rspec
Screenshots of project settings and builds status
1) What I've missed, why build is not triggering by commit to repo?
2) How to trigger build manually?
3) What is Timeout in project settings?
Found an issue - github webhooks could not reach my drone server due network settings.

Resources