Thank you Gary.
Larry
Thank you Gary.
Larry
Hi Gary,
Given you comments about Docker, I am taking a “detour” with a Udemy course on Docker and Kubernetes: https://www.udemy.com/share/103IaC3@nthI4EnwQuWX46qH7QkBqzmTdQXcPQW2YxDcBWXpg0UHOrSWm5SIzvtlscbF58VH/
Udemy course can be hit or miss. If you don't like the one you purchased, I recommend this guys courses. The are taught at a good level and the guy explains things very well and speaks clearly. I have taken several of his courses and he seems to have mastered the content. I used to have the all access subscription.
Thank you Gary. I will take a look.
Larry
Hi Gary,
I’ve mad some progress on both Mosh’s Ultimate Docker Course (68%) and the Udemy course (which includes Kubernetes) by Maximillian Schwartzmuller (36 out of 270 lectures). However I also don’t want to lose sight of the “prize” which is successfully getting some simple task code to run inside a container in PyCharm Professional. The Jetbrains docs for setting up docker and flask in PyCharm seem pretty clear though I have yet to try them out.
I don’t want to lose sight of how setting up a local neo4j database would fit in with the setup for docker and flask in PyCharm on a mac. Could you give me some sense of what I will have to do to also get neo4j running with docker and flask in PyCharm?
In case you want to see the Jetbrains docs they are at:
[
Docker-Compose: Getting Flask up and running | The PyCharm Blog |
Thank you Gary for time and guidance. I very much appreciate it.
Larry
This is my docker compose file for my neo4j database. It uses a neo4j docker file, so you don't need to build your own.
services:
neo4j-db:
image: neo4j:5.11-enterprise
ports:
- 7474:7474
- 7687:7687
environment:
- NEO4J_AUTH=neo4j/testuser
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
volumes:
- $HOME/neo4j/data:/data
- $HOME/neo4j/logs:/logs
- $HOME/neo4j/plugins:/plugins
- $HOME/neo4j/import:/import
- $HOME/neo4j/backups:/backups
save the text into a file with an extension 'yml' extension. You can spring up the container wit the following docker command, where the file name is compose-neo4j.yml
. $HOME is an environment variable pointing to my home directory.
docker compose -f compose-neo4j.yml up
Hi Gary,
Thanks again. Just to let you know where I am at. The pieces I need to put together in docker are flask and neo4j. Maybe some other things that I don’t know about yet. Given my (limited) understanding so far it looks like I will need to network 2 containers: one of neo4j and another python with flask. Each container will require its own .yml and Dockerfile. Does that sound right? Thanks Gary,
Larry
Hi Gary,
Thanks again. Just to let you know where I am at. The pieces I need to put together in docker are flask and neo4j. Maybe some other things that I don’t know about yet. Given my (limited) understanding so far it looks like I will need to network 2 containers: one of neo4j and another python with flask. Each container will require its own .yml and Dockerfile. Does that sound right? Thanks Gary,
Larry
| glilienfield Gary Lilienfield Neo4j Ninja
October 26 |
- | - |
This is my docker compose file for my neo4j database. It uses a neo4j docker file, so you don't need to build your own.
services:
neo4j-db:
image: neo4j:5.11-enterprise
ports:
- 7474:7474
- 7687:7687
environment:
- NEO4J_AUTH=neo4j/testuser
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
volumes:
- $HOME/neo4j/data:/data
- $HOME/neo4j/logs:/logs
- $HOME/neo4j/plugins:/plugins
- $HOME/neo4j/import:/import
- $HOME/neo4j/backups:/backups
save the text into a file with an extension 'yml' extension. You can spring up the container wit the following docker command, where the file name is compose-neo4j.yml
. $HOME is an environment variable pointing to my home directory.
docker compose -f compose-neo4j.yml up
That is correct. I have a docker container with just a neo4j database. Here I use a neo4j provided container. I spin it up via the compose file I gave you.
I have my own docker containers for each of my micro services. I create them with individual docker files and spin them all up with a single docker compose file.
Here is an example docker file for one of my java microservices. You will have to do something specify to python and flask.
As you can see, I start by using an alpine image (linux), add openJdk to it, add a user, copy my java jar to the container, and then tell docker how to launch the app.
FROM alpine:3.17.3
ARG version=1.0
RUN apk add openjdk17-jre
RUN addgroup service && adduser -S -G service service
USER service
COPY target/item-service-${version}-SNAPSHOT.jar itemService-${version}-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/itemService-1.0-SNAPSHOT.jar"]
The one thing that took me some time to figure out is how to have a micro service inside a container access neo4j within a container, when all on my local network. You can't use localhost, as the docker container thinks that is a url pointing to inside the container. You have to use something like this for your neo4j url bolt://host.docker.internal:7687
The docker compose file for all the services at once is the following:
services:
neo4j-db:
image: neo4j:5.11-enterprise
ports:
- 7474:7474
- 7687:7687
environment:
- NEO4J_AUTH=neo4j/testuser
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
volumes:
- $HOME/neo4j/data:/data
- $HOME/neo4j/logs:/logs
- $HOME/neo4j/plugins:/plugins
- $HOME/neo4j/import:/import
- $HOME/neo4j/backups:/backups
healthcheck:
test: "exit 0"
item-service:
image: gslogix/item-service
environment:
- spring.neo4j.uri=bolt://host.docker.internal:7687
- spring.neo4j.authentication.password=testuser
- spring.neo4j.authentication.username=neo4j
- command.line.runner.enabled=true
ports:
- 8080:8080
depends_on:
neo4j-db:
condition: service_healthy
order-service:
image: gslogix/order-service
environment:
- spring.neo4j.uri=bolt://host.docker.internal:7687
- spring.neo4j.authentication.password=testuser
- spring.neo4j.authentication.username=neo4j
- command.line.runner.enabled=true
ports:
- 8081:8081
depends_on:
neo4j-db:
condition: service_healthy
production-service:
image: gslogix/production-service
environment:
- spring.neo4j.uri=bolt://host.docker.internal:7687
- spring.neo4j.authentication.password=testuser
- spring.neo4j.authentication.username=neo4j
ports:
- 8082:8082
ui:
image: gslogix/gslogix_ui:latest
ports:
- 80:80
links:
- item-service
- order-service
Thank you very much Gary. I may have some questions after trying some things out.
Larry