Nditah / docker-go-neo4j

How to Set Up Docker for Neo4j and Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker-go-neo4j

  1. download the image for Neo4j and start the container in the background.
docker-compose up -d
  1. verify that the database is working by going to http://localhost:7474/

  2. In the Neo4j UI, enter neo4j as password and set testing as a new password.

  3. Then, when you're logged in, type :play movie-graph in the editor and press the play button on the right. :play movie-graph

  4. Add the backend service to the docker-compose.yml file

backend:
    container_name: 'api-go'
    build: './backend'
    ports:
      - '8080:8080'
    volumes:
      - './backend:/go/src/app'
    depends_on:
      - 'neo4j'
    networks:
        - neo4j_go_net

  1. Create a directory call backend. Inside that backend folder, create a file called Dockerfile
FROM golang:latest

WORKDIR /go/src/app
COPY . .

RUN go get github.com/pilu/fresh

CMD [ "fresh" ]

This file fetches the golang image from Docker Hub, sets up a working directory, copies everything from the backend folder into the working directory, installs the required packages, and runs the fresh command for hot reloading.

  1. Intialize the backend

go mod init github.com/Nditah/docker-go-neo4j/backend

  1. Reload docker-compose and you can view the app running at http://localhost:8081, where you'll see a list of movies in JSON format.

About

How to Set Up Docker for Neo4j and Go


Languages

Language:HTML 70.9%Language:Go 28.0%Language:Dockerfile 1.1%