├── .github └── workflows │ ├── release-full-platform.yml │ └── release-platform-memgraph-lab.yml ├── .gitignore ├── .gitmodules ├── Dockerfile ├── LICENSE ├── README.md ├── configs ├── programs │ ├── lab.conf │ └── memgraph.conf ├── supervisord-lab-only.conf ├── supervisord-memgraph-only.conf └── supervisord.conf ├── docker-compose.yml ├── init.ps1 ├── init.sh ├── memgraph_and_lab.Dockerfile ├── scripts ├── README.md ├── build_memgraph_native.sh ├── docker_image_mage.sh ├── docker_image_memgraph.sh ├── docker_image_platform.sh └── pack_memgraph_via_docker.sh └── tools └── remove_docker_tag.sh /.github/workflows/release-full-platform.yml: -------------------------------------------------------------------------------- 1 | name: Release full Memgraph Platform 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | memgraph_platform_version: 7 | description: "Memgraph Platform version." 8 | required: true 9 | memgraph_version: 10 | description: "Memgraph version that will be integrated into platform." 11 | required: true 12 | force_release: 13 | description: > 14 | "Force the release despite the version already exists on DockerHub." 15 | type: boolean 16 | required: false 17 | default: false 18 | docker_repository_name: 19 | description: "Dockerhub repository to upload to. (Mainly for testing)" 20 | required: false 21 | default: memgraph-platform 22 | 23 | env: 24 | DOCKER_ORGANIZATION_NAME: memgraph 25 | DOCKER_REPOSITORY_NAME: ${{ github.event.inputs.docker_repository_name }} 26 | 27 | # Reason for separating ARM and AMD is speed, buildx is extremely slow when 28 | # building for ARM on AMD, and it is better to use native ARM machine to build 29 | # that image 30 | jobs: 31 | release-memgraph-platform-amd: 32 | runs-on: [self-hosted, Linux, X64, Diff] 33 | steps: 34 | - name: Checkout repository and submodules 35 | uses: actions/checkout@v3 36 | with: 37 | fetch-depth: 0 38 | submodules: recursive 39 | token: ${{ secrets.PAT }} 40 | 41 | - name: Get Memgraph Lab release version 42 | run: | 43 | cd lab 44 | git fetch --all --tags 45 | MEMGRAPH_LAB_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 46 | echo $MEMGRAPH_LAB_VERSION 47 | echo "LAB_VERSION=${MEMGRAPH_LAB_VERSION:1}" >> $GITHUB_ENV 48 | 49 | - name: Get Memgraph Mage release version 50 | run: | 51 | cd mage 52 | git fetch --all --tags 53 | MEMGRAPH_MAGE_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 54 | echo $MEMGRAPH_MAGE_VERSION 55 | MEMGRAPH_MAGE_VERSION=${MEMGRAPH_MAGE_VERSION#v} 56 | echo "MAGE_VERSION=${MEMGRAPH_MAGE_VERSION%%-*}" >> $GITHUB_ENV 57 | 58 | - name: Set Memgraph Platform version 59 | run: | 60 | echo "PLATFORM_VERSION=${{ github.event.inputs.memgraph_platform_version }}-memgraph${{ github.event.inputs.memgraph_version }}-lab${{ env.LAB_VERSION }}-mage${{ env.MAGE_VERSION }}" >> $GITHUB_ENV 61 | 62 | - name: Set up QEMU 63 | uses: docker/setup-qemu-action@v2 64 | 65 | - name: Set up Docker Buildx 66 | id: buildx 67 | uses: docker/setup-buildx-action@v2 68 | 69 | - name: Available platforms 70 | run: echo ${{ steps.buildx.outputs.platforms }} 71 | 72 | - name: Log in to Docker Hub 73 | uses: docker/login-action@v2 74 | with: 75 | username: ${{ secrets.DOCKERHUB_USERNAME }} 76 | password: ${{ secrets.DOCKERHUB_TOKEN }} 77 | 78 | - name: Download memgraph binaries 79 | run: | 80 | curl -L https://download.memgraph.com/memgraph/v${{ github.event.inputs.memgraph_version }}/debian-11/memgraph_${{ github.event.inputs.memgraph_version }}-1_amd64.deb > memgraph-amd64.deb 81 | 82 | - name: Check if specified version is already pushed 83 | run: | 84 | EXISTS=$(docker manifest inspect $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }} > /dev/null; echo $?) 85 | echo $EXISTS 86 | if [[ ${EXISTS} -eq 0 ]]; then 87 | echo The specified version has been already released to DockerHub! 88 | if [[ ${{ github.event.inputs.force_release }} = true ]]; then 89 | echo Forcing the release 90 | else 91 | echo Stopping the release 92 | exit 1 93 | fi 94 | else 95 | echo All good the specified version has not been release to DockerHub 96 | fi 97 | 98 | - name: Build & push docker images 99 | run: | 100 | docker buildx build \ 101 | --build-arg BINARY_NAME="memgraph-" \ 102 | --build-arg NPM_PACKAGE_TOKEN="${{ secrets.PAT }}" \ 103 | --platform linux/amd64 \ 104 | --tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }}-amd \ 105 | --push . 106 | 107 | release-memgraph-platform-arm: 108 | runs-on: [self-hosted, ARM64] 109 | steps: 110 | - name: Checkout repository and submodules 111 | uses: actions/checkout@v3 112 | with: 113 | fetch-depth: 0 114 | submodules: recursive 115 | token: ${{ secrets.PAT }} 116 | 117 | - name: Get Memgraph Lab release version 118 | run: | 119 | cd lab 120 | git fetch --all --tags 121 | MEMGRAPH_LAB_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 122 | echo $MEMGRAPH_LAB_VERSION 123 | echo "LAB_VERSION=${MEMGRAPH_LAB_VERSION:1}" >> $GITHUB_ENV 124 | 125 | - name: Get Memgraph Mage release version 126 | run: | 127 | cd mage 128 | git fetch --all --tags 129 | MEMGRAPH_MAGE_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 130 | echo $MEMGRAPH_MAGE_VERSION 131 | MEMGRAPH_MAGE_VERSION=${MEMGRAPH_MAGE_VERSION#v} 132 | echo "MAGE_VERSION=${MEMGRAPH_MAGE_VERSION%%-*}" >> $GITHUB_ENV 133 | 134 | - name: Set Memgraph Platform version 135 | run: | 136 | echo "PLATFORM_VERSION=${{ github.event.inputs.memgraph_platform_version }}-memgraph${{ github.event.inputs.memgraph_version }}-lab${{ env.LAB_VERSION }}-mage${{ env.MAGE_VERSION }}" >> $GITHUB_ENV 137 | 138 | - name: Set up QEMU 139 | uses: docker/setup-qemu-action@v2 140 | 141 | - name: Log in to Docker Hub 142 | run: | 143 | security unlock-keychain -p ${{ secrets.HOST_PASSWORD }} 144 | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} 145 | 146 | - name: Set up Docker Buildx 147 | id: buildx 148 | uses: docker/setup-buildx-action@v2 149 | 150 | - name: Available platforms 151 | run: echo ${{ steps.buildx.outputs.platforms }} 152 | 153 | - name: Download memgraph binaries 154 | run: | 155 | curl -L https://download.memgraph.com/memgraph/v${{ github.event.inputs.memgraph_version }}/debian-11-aarch64/memgraph_${{ github.event.inputs.memgraph_version }}-1_arm64.deb > memgraph-arm64.deb 156 | 157 | - name: Check if specified version is already pushed 158 | run: | 159 | EXISTS=$(docker manifest inspect $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }} > /dev/null; echo $?) 160 | echo $EXISTS 161 | if [[ ${EXISTS} -eq 0 ]]; then 162 | echo The specified version has been already released to DockerHub! 163 | if [[ ${{ github.event.inputs.force_release }} = true ]]; then 164 | echo Forcing the release 165 | else 166 | echo Stopping the release 167 | exit 1 168 | fi 169 | else 170 | echo All good the specified version has not been release to DockerHub 171 | fi 172 | 173 | - name: Build & push docker images 174 | run: | 175 | docker buildx build \ 176 | --build-arg BINARY_NAME="memgraph-" \ 177 | --build-arg NPM_PACKAGE_TOKEN="${{ secrets.PAT }}" \ 178 | --platform linux/arm64 \ 179 | --tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }}-arm \ 180 | --push . 181 | 182 | merge-images: 183 | runs-on: ubuntu-latest 184 | needs: [release-memgraph-platform-arm, release-memgraph-platform-amd] 185 | steps: 186 | - name: Checkout repository and submodules 187 | uses: actions/checkout@v3 188 | with: 189 | fetch-depth: 0 190 | submodules: recursive 191 | token: ${{ secrets.PAT }} 192 | 193 | - name: Log in to Docker Hub 194 | uses: docker/login-action@v2 195 | with: 196 | username: ${{ secrets.DOCKERHUB_USERNAME }} 197 | password: ${{ secrets.DOCKERHUB_TOKEN }} 198 | 199 | - name: Get Memgraph Lab release version 200 | run: | 201 | cd lab 202 | git fetch --all --tags 203 | MEMGRAPH_LAB_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 204 | echo $MEMGRAPH_LAB_VERSION 205 | echo "LAB_VERSION=${MEMGRAPH_LAB_VERSION:1}" >> $GITHUB_ENV 206 | 207 | - name: Get Memgraph Mage release version 208 | run: | 209 | cd mage 210 | git fetch --all --tags 211 | MEMGRAPH_MAGE_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 212 | echo $MEMGRAPH_MAGE_VERSION 213 | MEMGRAPH_MAGE_VERSION=${MEMGRAPH_MAGE_VERSION#v} 214 | echo "MAGE_VERSION=${MEMGRAPH_MAGE_VERSION%%-*}" >> $GITHUB_ENV 215 | 216 | - name: Set Memgraph Platform version 217 | run: | 218 | echo "PLATFORM_VERSION=${{ github.event.inputs.memgraph_platform_version }}-memgraph${{ github.event.inputs.memgraph_version }}-lab${{ env.LAB_VERSION }}-mage${{ env.MAGE_VERSION }}" >> $GITHUB_ENV 219 | 220 | - name: Set up QEMU 221 | uses: docker/setup-qemu-action@v2 222 | 223 | - name: Set up Docker Buildx 224 | id: buildx 225 | uses: docker/setup-buildx-action@v2 226 | 227 | - name: Build single image 228 | run: | 229 | docker buildx imagetools create \ 230 | --tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }} \ 231 | --tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:latest \ 232 | $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }}-arm \ 233 | $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }}-amd 234 | 235 | - name: Remove redundant ARM 236 | run: | 237 | ./tools/remove_docker_tag.sh ${{ secrets.DOCKERHUB_USERNAME }} \ 238 | ${{ secrets.DOCKERHUB_TOKEN }} \ 239 | $DOCKER_ORGANIZATION_NAME \ 240 | $DOCKER_REPOSITORY_NAME \ 241 | ${{ env.PLATFORM_VERSION }}-arm 242 | 243 | - name: Remove redundant AMD 244 | run: | 245 | ./tools/remove_docker_tag.sh ${{ secrets.DOCKERHUB_USERNAME }} \ 246 | ${{ secrets.DOCKERHUB_TOKEN }} \ 247 | $DOCKER_ORGANIZATION_NAME \ 248 | $DOCKER_REPOSITORY_NAME \ 249 | ${{ env.PLATFORM_VERSION }}-amd 250 | -------------------------------------------------------------------------------- /.github/workflows/release-platform-memgraph-lab.yml: -------------------------------------------------------------------------------- 1 | name: Release Memgraph Platform without mage 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | memgraph_platform_version: 7 | description: "Memgraph Platform version." 8 | required: true 9 | memgraph_version: 10 | description: "Memgraph version that will be integrated into platform." 11 | required: true 12 | force_release: 13 | description: > 14 | "Force the release despite the version already exists on DockerHub." 15 | type: boolean 16 | required: false 17 | default: false 18 | docker_repository_name: 19 | description: "Dockerhub repository to upload to. (Mainly for testing)" 20 | required: false 21 | default: memgraph-platform 22 | 23 | env: 24 | DOCKER_ORGANIZATION_NAME: memgraph 25 | DOCKER_REPOSITORY_NAME: ${{ github.event.inputs.docker_repository_name }} 26 | 27 | # Reason for separating ARM and AMD is speed, buildx is extremely slow when 28 | # building for ARM on AMD, and it is better to use native ARM machine to build 29 | # that image 30 | jobs: 31 | release-memgraph-platform-without-mage: 32 | runs-on: [self-hosted, Linux, X64, Diff] 33 | steps: 34 | - name: Checkout repository and submodules 35 | uses: actions/checkout@v3 36 | with: 37 | fetch-depth: 0 38 | submodules: recursive 39 | token: ${{ secrets.PAT }} 40 | 41 | - name: Get Memgraph Lab release version 42 | run: | 43 | cd lab 44 | git fetch --all --tags 45 | MEMGRAPH_LAB_VERSION=$(git rev-parse --verify HEAD | git tag --contains) 46 | echo $MEMGRAPH_LAB_VERSION 47 | echo "LAB_VERSION=${MEMGRAPH_LAB_VERSION:1}" >> $GITHUB_ENV 48 | 49 | - name: Set Memgraph Platform version 50 | run: | 51 | echo "PLATFORM_VERSION=${{ github.event.inputs.memgraph_platform_version }}-memgraph${{ github.event.inputs.memgraph_version }}-lab${{ env.LAB_VERSION }}" >> $GITHUB_ENV 52 | 53 | - name: Set up QEMU 54 | uses: docker/setup-qemu-action@v2 55 | 56 | - name: Set up Docker Buildx 57 | id: buildx 58 | uses: docker/setup-buildx-action@v2 59 | 60 | - name: Available platforms 61 | run: echo ${{ steps.buildx.outputs.platforms }} 62 | 63 | - name: Log in to Docker Hub 64 | uses: docker/login-action@v2 65 | with: 66 | username: ${{ secrets.DOCKERHUB_USERNAME }} 67 | password: ${{ secrets.DOCKERHUB_TOKEN }} 68 | 69 | - name: Download memgraph binaries 70 | run: | 71 | curl -L https://download.memgraph.com/memgraph/v${{ github.event.inputs.memgraph_version }}/debian-11/memgraph_${{ github.event.inputs.memgraph_version }}-1_amd64.deb > memgraph-amd64.deb 72 | curl -L https://download.memgraph.com/memgraph/v${{ github.event.inputs.memgraph_version }}/debian-11-aarch64/memgraph_${{ github.event.inputs.memgraph_version }}-1_arm64.deb > memgraph-arm64.deb 73 | 74 | - name: Check if specified version is already pushed 75 | run: | 76 | EXISTS=$(docker manifest inspect $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }} > /dev/null; echo $?) 77 | echo $EXISTS 78 | if [[ ${EXISTS} -eq 0 ]]; then 79 | echo The specified version has been already released to DockerHub! 80 | if [[ ${{ github.event.inputs.force_release }} = true ]]; then 81 | echo Forcing the release 82 | else 83 | echo Stopping the release 84 | exit 1 85 | fi 86 | else 87 | echo All good the specified version has not been release to DockerHub 88 | fi 89 | 90 | - name: Build & push docker image 91 | run: | 92 | docker buildx build \ 93 | --build-arg BINARY_NAME="memgraph-" \ 94 | --build-arg NPM_PACKAGE_TOKEN="${{ secrets.PAT }}" \ 95 | --platform linux/amd64,linux/arm64 \ 96 | --tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.PLATFORM_VERSION }} \ 97 | --file memgraph_and_lab.Dockerfile \ 98 | --push . 99 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | scripts/dist 2 | *.deb 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "mage"] 2 | path = mage 3 | url = https://github.com/memgraph/mage.git 4 | branch = main 5 | [submodule "lab"] 6 | path = lab 7 | url = https://github.com/memgraph/lab.git 8 | branch = dev 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # For mage 2 | ARG PY_VERSION_DEFAULT=3.9 3 | 4 | FROM debian:bullseye as base 5 | 6 | ARG TARGETARCH 7 | ARG PY_VERSION_DEFAULT 8 | ENV PY_VERSION ${PY_VERSION_DEFAULT} 9 | 10 | # Essentials for production 11 | RUN apt-get update && apt-get install -y \ 12 | libcurl4 `memgraph` \ 13 | libpython${PY_VERSION} `memgraph` \ 14 | libssl-dev `memgraph` \ 15 | openssl `memgraph` \ 16 | build-essential `mage-memgraph` \ 17 | cmake `mage-memgraph` \ 18 | curl `mage-memgraph` \ 19 | g++ `mage-memgraph` \ 20 | python3 `mage-memgraph` \ 21 | python3-pip `mage-memgraph` \ 22 | python3-setuptools `mage-memgraph` \ 23 | python3-dev `mage-memgraph` \ 24 | clang `mage-memgraph` \ 25 | git `mage-memgraph` \ 26 | unixodbc-dev `mage-memgraph` \ 27 | supervisor `memgraph`\ 28 | netcat `memgraph-platform` \ 29 | --no-install-recommends \ 30 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 31 | 32 | ################################################################################################################################################### 33 | 34 | # MAGE 35 | FROM base as mage-dev 36 | 37 | WORKDIR /mage 38 | COPY mage /mage 39 | 40 | RUN curl https://sh.rustup.rs -sSf | sh -s -- -y 41 | 42 | ENV PATH="/root/.cargo/bin:${PATH}" 43 | 44 | RUN python3 -m pip install --upgrade pip \ 45 | && python3 -m pip install --default-timeout=1000 -r /mage/python/requirements.txt 46 | 47 | RUN python3 -m pip --default-timeout=1000 --no-cache-dir install torch-sparse torch-cluster torch-spline-conv \ 48 | torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu102.html 49 | 50 | RUN python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ 51 | 52 | # DGL build from source 53 | RUN git clone --recurse-submodules -b 0.9.x https://github.com/dmlc/dgl.git \ 54 | && cd dgl && mkdir build && cd build && cmake .. \ 55 | && make -j4 && cd ../python && python3 setup.py install 56 | 57 | ################################################################################################################################################### 58 | 59 | # Lab: Build backend 60 | FROM node:18.15-alpine as lab-base 61 | 62 | WORKDIR /app 63 | # Python make and g++ are needed for arm node-gyp package 64 | RUN apk update && apk add git python3 make g++ 65 | ARG NPM_PACKAGE_TOKEN 66 | 67 | COPY lab/frontend/.npmrc ./frontend/ 68 | COPY lab/frontend/package*.json ./frontend/ 69 | RUN echo '//npm.pkg.github.com/:_authToken=${NPM_PACKAGE_TOKEN}' | tee -a ./frontend/.npmrc 70 | 71 | COPY lab/package*.json ./ 72 | 73 | RUN npm config rm proxy 74 | RUN npm config rm https-proxy 75 | RUN npm config set legacy-peer-deps true 76 | RUN npm install && npm cache clean --force 77 | RUN rm -f ./frontend/.npmrc 78 | 79 | COPY lab/tsconfig.json . 80 | COPY lab/tsconfig.build.json . 81 | COPY lab/.env . 82 | 83 | RUN sed -i "s/NODE_ENV=local/NODE_ENV=platform/" ./.env 84 | 85 | COPY lab/backend/ ./backend/ 86 | COPY lab/frontend/ ./frontend/ 87 | 88 | RUN npm run build 89 | 90 | RUN cd frontend && npm run build:production 91 | 92 | ################################################################################################################################################### 93 | 94 | FROM base as final 95 | 96 | # Copy the backend artifacts 97 | COPY --from=lab-base /app/dist-backend /lab/dist-backend 98 | COPY --from=lab-base /app/dist-frontend /lab/dist-frontend 99 | 100 | COPY --from=lab-base /app/node_modules /lab/node_modules 101 | COPY --from=lab-base /app/.env /lab/.env 102 | 103 | # This is needed for lab 104 | RUN apt-get update \ 105 | && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ 106 | && apt-get install -y nodejs \ 107 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 108 | 109 | # This is needed for memgraph built in algos 110 | RUN pip3 install --default-timeout=1000 networkx==2.4 numpy==1.21.4 scipy==1.7.3 111 | 112 | #copy modules 113 | COPY --from=mage-dev /usr/lib/memgraph/query_modules/ /usr/lib/memgraph/query_modules/ 114 | 115 | # rm modules with issues (temporary) 116 | RUN rm /usr/lib/memgraph/query_modules/node_classification.py \ 117 | && rm /usr/lib/memgraph/query_modules/link_prediction.py \ 118 | && rm /usr/lib/memgraph/query_modules/text.so 119 | 120 | #copy python build 121 | COPY --from=mage-dev /usr/local/lib/python${PY_VERSION}/ /usr/local/lib/python${PY_VERSION}/ 122 | 123 | COPY memgraph-${TARGETARCH}.deb . 124 | 125 | RUN dpkg -i memgraph-${TARGETARCH}.deb && rm memgraph-${TARGETARCH}.deb 126 | 127 | RUN rm -rf /mage \ 128 | && export PATH="/usr/local/lib/python${PY_VERSION}:${PATH}" \ 129 | && apt-get -y --purge autoremove clang git curl python3-pip python3-dev cmake build-essential \ 130 | && apt-get clean 131 | 132 | EXPOSE 3000 7444 7687 133 | COPY configs/ /etc/supervisor/ 134 | 135 | RUN chmod 777 -R /var/log/memgraph 136 | RUN chmod 777 -R /var/lib/memgraph 137 | RUN chmod 777 -R /usr/lib/memgraph 138 | RUN chmod 777 /usr/lib/memgraph/memgraph 139 | 140 | ENV MEMGRAPH="--also-log-to-stderr" 141 | 142 | ENTRYPOINT [ "/usr/bin/supervisord" ] 143 | CMD [ "-c", "/etc/supervisor/supervisord.conf" ] 144 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

One command to run it all.

5 | 6 |

7 | 8 | license 9 |

10 | 11 | ## :runner: Quick start 12 | 13 | With Docker running on your system and ports 7687, 7444 and 3000 available, run one of the following commands to download Memgraph Platform Docker Compose file and start Memgraph and Memgraph Lab services: 14 | 15 | **Linux/macOS** 16 | 17 | ``` 18 | curl https://install.memgraph.com | sh 19 | ``` 20 | 21 | **Windows** 22 | 23 | ``` 24 | iwr https://windows.memgraph.com | iex 25 | ``` 26 | 27 | By running `docker ps`, you'll notice `memgraph-mage` and `memgraph-lab` containers running. If you head over to `localhost:3000`, Quick Connect in Memgraph Lab will detect Memgraph running on your system. Check out the basic [Docker Compose file](./docker-compose.yml) and update it to fit your needs. 28 | 29 | To start `mgconsole`, run the following command: 30 | 31 | ``` 32 | # with `docker ps` get the Memgraph container id 33 | docker exec -ti mgconsole 34 | ``` 35 | 36 | ## :clipboard: Description 37 | 38 | This repository serves as a Docker package builder for the Memgraph ecosystem, consisting of: 39 | - [MemgraphDB](https://github.com/memgraph/memgraph) 40 | - [mgconsole](https://github.com/memgraph/mgconsole) 41 | - [MAGE](https://github.com/memgraph/mage) 42 | - [Memgraph Lab](https://memgraph.com/docs/data-visualization) 43 | 44 | Here are the Docker images which can be built from this repository: 45 | - [Memgraph Docker image](https://hub.docker.com/r/memgraph/memgraph) 46 | - [Memgraph MAGE Docker image](https://hub.docker.com/r/memgraph/memgraph-mage) 47 | - [Memgraph Lab Docker image](https://hub.docker.com/r/memgraph/lab) 48 | - ([*deprecated*](#exclamation-deprecated-memgraph-platform-docker-image)) [Memgraph Platform Docker image](https://hub.docker.com/r/memgraph/memgraph-platform) 49 | 50 | 51 | ## :exclamation: (Deprecated) Memgraph Platform Docker image 52 | 53 | The last Memgraph Platform image published on Docker Hub is 2.14.1. In the future, from Memgraph 2.15, **Memgraph Platform image will no longer be published**, and [Docker Compose](./docker-compose.yml) containing Memgraph MAGE and Lab services will replace it. 54 | 55 | 56 | You can start Memgraph Platform with: 57 | 58 | ``` 59 | docker run -p 3000:3000 -p 7444:7444 -p 7687:7687 --name memgraph memgraph/memgraph-platform 60 | ``` 61 | 62 | ### How to start mgconsole 63 | 64 | Start `mgconsole` with: 65 | 66 | ``` 67 | # get the running-container-id with `docker ps` 68 | docker exec -ti mgconsole 69 | 70 | # or 71 | docker run -ti --entrypoint=mgconsole memgraph/memgraph-platform 72 | ``` 73 | 74 | When connecting to local Memgraph with `mgconsole` on Windows and Mac, make 75 | sure to provide the following argument `--host host.docker.internal`: 76 | 77 | ``` 78 | docker run -ti --entrypoint=mgconsole memgraph/memgraph-platform --host host.docker.internal 79 | ``` 80 | 81 | ### How to start only Lab 82 | 83 | Run only the Lab with the following command: 84 | 85 | ``` 86 | docker run -p 3000:3000 memgraph/memgraph-platform -c /etc/supervisor/supervisord-lab-only.conf 87 | ``` 88 | 89 | ### How to start only Memgraph 90 | 91 | Run only Memgraph with the following command: 92 | 93 | ``` 94 | docker run -p 7687:7687 memgraph/memgraph-platform -c /etc/supervisor/supervisord-memgraph-only.conf 95 | ``` 96 | 97 | 98 | ### :hourglass: Versioning 99 | 100 | The versioning is transparent in the sense that we explicitly state which 101 | version of software is included, and it looks like this: 102 | 103 | `memgraph/memgraph-platform:2.5.0-memgraph2.4-lab2.2.2-mage1.3.5` 104 | 105 | and just by looking at each of the Memgraph Platform version, you can know which 106 | versions of software it contains without looking at details in release notes. 107 | 108 | ### :whale: Docker build 109 | 110 | To build docker image, you need to provide two build arguments: 111 | 112 | * `TARGETARCH` - a suffix of the specific local Memgraph debian version; for example if 113 | you have a local debian package `memgraph-2.10-arm64.deb` that you want to build platform for, use 114 | the following build argument: `--build-arg="TARGETARCH=2.10-arm64"`. 115 | 116 | * `NPM_PACKAGE_TOKEN` - npm token to install private libraries that Memgraph Lab uses, set 117 | it up with the following argument: `--build-arg="NPM_PACKAGE_TOKEN=ghp_6..."` 118 | 119 | 1. Run `docker build --build-arg="TARGETARCH=..." --build-arg="NPM_PACKAGE_TOKEN=..." . -t memgraph-platform` 120 | 2. Run `docker run -p 3000:3000 -p 7687:7687 memgraph-platform` 121 | 3. Go to `http://localhost:3000` and connect to Memgraph database with Memgraph 122 | Lab in order to test it out 123 | 124 |

125 | 126 | Back to top 127 | 128 |

129 | -------------------------------------------------------------------------------- /configs/programs/lab.conf: -------------------------------------------------------------------------------- 1 | # ~ supervisord config ~ 2 | # Change the file name to `disabled-...` to disable the program below 3 | 4 | [program:lab] 5 | directory=/lab 6 | startretries=0 7 | command=/bin/bash -c "node dist-backend/server.js" 8 | stdout_logfile=/dev/stdout 9 | stdout_logfile_maxbytes=0 10 | stderr_logfile=/dev/stderr 11 | stderr_logfile_maxbytes=0 12 | -------------------------------------------------------------------------------- /configs/programs/memgraph.conf: -------------------------------------------------------------------------------- 1 | # ~ supervisord config ~ 2 | # Change the file name to `disabled-...` to disable the program below 3 | 4 | [program:memgraph] 5 | directory=/usr/lib/memgraph 6 | command=/bin/bash -c "runuser -u memgraph /usr/lib/memgraph/memgraph -- %(ENV_MEMGRAPH)s" 7 | priority=1 8 | startretries=0 9 | stdout_logfile=/dev/stdout 10 | stdout_logfile_maxbytes=0 11 | stderr_logfile=/dev/stderr 12 | stderr_logfile_maxbytes=0 13 | -------------------------------------------------------------------------------- /configs/supervisord-lab-only.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | 5 | [include] 6 | files=programs/lab.conf 7 | -------------------------------------------------------------------------------- /configs/supervisord-memgraph-only.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | 5 | [include] 6 | files=programs/memgraph.conf 7 | -------------------------------------------------------------------------------- /configs/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | 5 | [include] 6 | files=programs/*.conf 7 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | memgraph: 3 | image: memgraph/memgraph-mage:latest 4 | container_name: memgraph-mage 5 | pull_policy: always 6 | ports: 7 | - "7687:7687" 8 | - "7444:7444" 9 | command: ["--log-level=TRACE"] 10 | 11 | lab: 12 | image: memgraph/lab:latest 13 | container_name: memgraph-lab 14 | pull_policy: always 15 | ports: 16 | - "3000:3000" 17 | depends_on: 18 | - memgraph 19 | environment: 20 | - QUICK_CONNECT_MG_HOST=memgraph 21 | - QUICK_CONNECT_MG_PORT=7687 22 | -------------------------------------------------------------------------------- /init.ps1: -------------------------------------------------------------------------------- 1 | # Set strict mode 2 | Set-StrictMode -Version Latest 3 | 4 | $CHECKMARK_SYMBOL = @{ 5 | Object = [Char]8730 6 | ForegroundColor = 'Green' 7 | NoNewLine = $false 8 | } 9 | 10 | # Function to check command dependencies 11 | function check_cmd_dep { 12 | Param( 13 | [string]$cmd 14 | ) 15 | if ($cmd -eq "docker compose") { 16 | $check_cmd = docker compose 2>$null 17 | } else { 18 | $check_cmd = Get-Command $cmd 2>$null 19 | } 20 | if ($check_cmd) { 21 | Write-Host "$cmd " -NoNewLine 22 | Write-Host @CHECKMARK_SYMBOL 23 | return $true 24 | } else { 25 | Write-Host "$cmd " 26 | Write-Host "X" -ForegroundColor Red 27 | return $false 28 | } 29 | } 30 | 31 | # Check required commands 32 | Write-Host "Checking for requirements on this machine:" -ForegroundColor Yellow 33 | $check_deps = $true 34 | if (-not (check_cmd_dep "Invoke-WebRequest")) { 35 | $check_deps = $false 36 | } 37 | if (-not (check_cmd_dep "docker")) { 38 | $check_deps = $false 39 | } 40 | if (-not (check_cmd_dep "docker compose")) { 41 | $check_deps = $false 42 | } 43 | if (-not (check_cmd_dep "mkdir")) { 44 | $check_deps = $false 45 | } 46 | if (-not (check_cmd_dep "Get-Location")) { 47 | $check_deps = $false 48 | } 49 | if (-not $check_deps) { 50 | Write-Host "All requirements must be satisfied to run this script!" -ForegroundColor Red 51 | exit 1 52 | } 53 | 54 | $DIR = Get-Location 55 | $MGPLAT_DIR = "$DIR\memgraph-platform" 56 | $MGPLAT_COMPOSE_PATH = "$MGPLAT_DIR\docker-compose.yml" 57 | $DOCKER_COMPOSE_URL = "https://raw.githubusercontent.com/memgraph/memgraph-platform/main/docker-compose.yml" 58 | 59 | # Check if compose file already exists 60 | if (Test-Path $MGPLAT_COMPOSE_PATH) { 61 | Write-Host "Overwriting docker compose file found at: $MGPLAT_COMPOSE_PATH" -ForegroundColor Yellow 62 | } elseif (-not (Test-Path $MGPLAT_DIR)) { 63 | New-Item -ItemType Directory -Path $MGPLAT_DIR | Out-Null 64 | } 65 | 66 | # Download compose file 67 | Write-Host "Downloading docker compose file to: $MGPLAT_COMPOSE_PATH" -ForegroundColor Yellow 68 | Invoke-WebRequest -Uri $DOCKER_COMPOSE_URL -OutFile "$MGPLAT_COMPOSE_PATH" 69 | if (-not $?) { 70 | Write-Host "Something went wrong when downloading docker-compose.yml from $DOCKER_COMPOSE_URL" -ForegroundColor Red 71 | } 72 | 73 | # Run compose 74 | Set-Location $MGPLAT_DIR 75 | Write-Host "Pulling memgraph/lab:latest and memgraph/memgraph-mage:latest" -ForegroundColor Yellow 76 | docker pull memgraph/lab:latest 77 | docker pull memgraph/memgraph-mage:latest 78 | Write-Host "Spinning up memgraph lab and memgraph with mage using docker compose file from: $MGPLAT_COMPOSE_PATH" -ForegroundColor Yellow 79 | docker compose up 80 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -eu 2 | 3 | OS=$(uname -s) 4 | ARCH=$(uname -m) 5 | 6 | CHECK_UNICODE="\xE2\x9C\x94" 7 | FAIL_UNICODE="\033[1mx\033[0m" 8 | 9 | if [ "${OS}" = "Linux" ] 10 | then 11 | CMD_PREFIX="/bin/" 12 | elif [ "${OS}" = "Darwin" ] 13 | then 14 | CMD_PREFIX="" 15 | else 16 | CMD_PREFIX="" 17 | fi 18 | 19 | msg_out() { 20 | ${CMD_PREFIX}echo -e "$1" 21 | } 22 | 23 | err_out() { 24 | msg_out "$(bold "ERROR"): $1" >&2 25 | exit 1 26 | } 27 | 28 | bold() { 29 | msg_out "\033[1m${1}\033[0m" 30 | } 31 | 32 | check_cmd_dep() { 33 | local check_cmd="command -V ${CMD_PREFIX}$1" 34 | if [ "$1" = "docker compose" ]; then 35 | check_cmd="${CMD_PREFIX}docker compose version" 36 | fi 37 | if $check_cmd > /dev/null 2>&1; then 38 | msg_out "$1 $CHECK_UNICODE" 39 | return 0 40 | else 41 | msg_out "$1 $(bold "x")" 42 | $check_cmd 43 | return 1 44 | fi 45 | } 46 | 47 | # Check required commands 48 | msg_out "$(bold "Checking for requirements on this machine:")" 49 | check_deps=1 50 | if check_cmd_dep "curl"; then 51 | _download_cmd=curl 52 | elif check_cmd_dep "wget"; then 53 | _download_cmd=wget 54 | else 55 | check_deps=0 56 | eerr_out "you need to have 'curl' or 'wget' installed" 57 | fi 58 | check_cmd_dep "docker" || check_deps=0 59 | check_cmd_dep "docker compose" || check_deps=0 60 | check_cmd_dep "mkdir" || check_deps=0 61 | check_cmd_dep "pwd" || check_deps=0 62 | if [ "$check_deps" -eq 0 ]; then 63 | err_out "All requirements must be satisfied to run this script!" 64 | fi 65 | 66 | DIR=$(${CMD_PREFIX}pwd) 67 | MGPLAT_DIR="$DIR/memgraph-platform" 68 | MGPLAT_COMPOSE_PATH="$MGPLAT_DIR/docker-compose.yml" 69 | DOCKER_COMPOSE_URL="https://raw.githubusercontent.com/memgraph/memgraph-platform/main/docker-compose.yml" 70 | 71 | # Check if compose file already exists 72 | if [ -f "$MGPLAT_COMPOSE_PATH" ]; then 73 | msg_out "\n$(bold "Overwriting docker compose file found at:") $MGPLAT_COMPOSE_PATH" 74 | elif [ ! -d $MGPLAT_DIR ]; then 75 | ${CMD_PREFIX}mkdir -p $MGPLAT_DIR 76 | fi 77 | 78 | # Download compose file 79 | msg_out "\n$(bold "Downloading docker compose file to:") $MGPLAT_COMPOSE_PATH" 80 | ${CMD_PREFIX}$_download_cmd $DOCKER_COMPOSE_URL -o "$MGPLAT_DIR/docker-compose.yml" || \ 81 | err_out "Something went wrong when dowloading docker-compose.yml from $DOCKER_COMPOSE_URL" 82 | 83 | # Run compose 84 | cd $MGPLAT_DIR 85 | msg_out "\n$(bold "Spinning up memgraph lab and memgraph with mage using docker compose file from:") $MGPLAT_COMPOSE_PATH" 86 | ${CMD_PREFIX}docker compose up 87 | -------------------------------------------------------------------------------- /memgraph_and_lab.Dockerfile: -------------------------------------------------------------------------------- 1 | # Lab: Build backend 2 | FROM node:18.15-alpine as lab-base 3 | 4 | WORKDIR /app 5 | # Python make and g++ are needed for arm node-gyp package 6 | RUN apk update && apk add git python3 make g++ 7 | ARG NPM_PACKAGE_TOKEN 8 | 9 | COPY lab/frontend/.npmrc ./frontend/ 10 | COPY lab/frontend/package*.json ./frontend/ 11 | COPY lab/frontend/memgraph-orb-*.tgz ./frontend/ 12 | RUN echo '//npm.pkg.github.com/:_authToken=${NPM_PACKAGE_TOKEN}' | tee -a ./frontend/.npmrc 13 | 14 | COPY lab/package*.json ./ 15 | 16 | RUN npm config rm proxy 17 | RUN npm config rm https-proxy 18 | RUN npm config set legacy-peer-deps true 19 | RUN npm install && npm cache clean --force 20 | RUN rm -f ./frontend/.npmrc 21 | 22 | COPY lab/tsconfig.json . 23 | COPY lab/tsconfig.build.json . 24 | COPY lab/.env . 25 | 26 | RUN sed -i "s/NODE_ENV=local/NODE_ENV=platform/" ./.env 27 | 28 | COPY lab/backend/ ./backend/ 29 | COPY lab/frontend/ ./frontend/ 30 | 31 | RUN npm run build 32 | 33 | RUN cd frontend && npm run build:production 34 | 35 | FROM debian:bullseye 36 | # Copy the backend artifacts 37 | COPY --from=lab-base /app/dist-backend /lab/dist-backend 38 | COPY --from=lab-base /app/dist-frontend /lab/dist-frontend 39 | 40 | COPY --from=lab-base /app/node_modules /lab/node_modules 41 | COPY --from=lab-base /app/.env /lab/.env 42 | 43 | # Building and Memgraph 44 | RUN apt-get clean && \ 45 | apt-get update && \ 46 | apt-get install -f -y \ 47 | python3-setuptools \ 48 | build-essential \ 49 | cmake \ 50 | curl \ 51 | git \ 52 | netcat \ 53 | libcurl4 \ 54 | libssl1.1 \ 55 | openssl \ 56 | python3 \ 57 | python3-pip \ 58 | python3-dev \ 59 | supervisor \ 60 | --no-install-recommends 61 | 62 | RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ 63 | && apt-get install -y nodejs \ 64 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 65 | 66 | RUN pip3 install networkx==2.4 numpy==1.21.4 scipy==1.7.3 67 | 68 | ARG TARGETARCH 69 | 70 | # Install memgraph 71 | COPY memgraph-${TARGETARCH}.deb . 72 | RUN dpkg -i memgraph-${TARGETARCH}.deb && rm memgraph-${TARGETARCH}.deb 73 | 74 | EXPOSE 3000 7444 7687 75 | COPY configs/ /etc/supervisor/ 76 | 77 | RUN chmod 777 -R /var/log/memgraph 78 | RUN chmod 777 -R /var/lib/memgraph 79 | RUN chmod 777 -R /usr/lib/memgraph 80 | RUN chmod 777 /usr/lib/memgraph/memgraph 81 | 82 | ENV MEMGRAPH="--also-log-to-stderr" 83 | 84 | ENTRYPOINT [ "/usr/bin/supervisord" ] 85 | CMD [ "-c", "/etc/supervisor/supervisord.conf" ] 86 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | # Scripts for creating custom memgraph packages and docker images 2 | 3 | Run `{script}.sh -h` to figure the details and how to start building. 4 | 5 | ## Notes 6 | 7 | * If you need builder image for any supported operating system, please take a 8 | look under `memgraph/release/package/run.sh`. Under the 9 | `memgraph/release/package/` there are Dockerfiles to build builder 10 | containers. 11 | * Lab is a private repo so this build is unavailable to public 12 | (`docker_image_platform.sh`). You can still build Memgraph + MAGE and use 13 | downloaded Lab with your image. 14 | 15 | ## Loading custom docker image 16 | 17 | Docker image can be loaded with (it takes some time): 18 | ``` 19 | docker load -i .tar.gz 20 | ``` 21 | and then used for example like this: 22 | ``` 23 | docker run -it --rm -p 7687:7687 --name 24 | ``` 25 | Platform image has a specific run command, please refer to the root of this repo. 26 | -------------------------------------------------------------------------------- /scripts/build_memgraph_native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # NOTE: -u is not an option here because toolchain activate fails (a better 3 | # ZSH_NAME check required). 4 | set -eo pipefail 5 | DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 6 | 7 | MGPLAT_TOOLCHAIN_ROOT="${MGPLAT_TOOLCHAIN_ROOT:-/opt/toolchain-v4}" 8 | MGPLAT_MG_ROOT="${MGPLAT_MG_ROOT:-$DIR/../mage/cpp/memgraph}" 9 | MGPLAT_MG_TAG="${MGPLAT_MG_TAG:-master}" 10 | MGPLAT_MG_BUILD_TYPE="${MGPLAT_MG_BUILD_TYPE:-RelWithDebInfo}" 11 | if [[ "$OSTYPE" == "linux-gnu"* ]]; then 12 | MGPLAT_CORES="${MGPLAT_CORES:-$(nproc)}" 13 | elif [[ "$OSTYPE" == "darwin"* ]]; then 14 | MGPLAT_CORES="${MGPLAT_CORES:-$(sysctl -n hw.physicalcpu)}" 15 | else 16 | MGPLAT_CORES="${MGPLAT_CORES:-8}" 17 | fi 18 | declare -A MGPLAT_CPACK 19 | MGPLAT_CPACK[ubuntu]="cpack -G DEB --config ../CPackConfig.cmake" 20 | MGPLAT_CPACK[debian]="cpack -G DEB --config ../CPackConfig.cmake" 21 | MGPLAT_DIST_BINARY="$DIR/dist/binary" 22 | print_help() { 23 | echo -e "Builds memgraph on natively supported operating systems." 24 | echo -e "Can be used natively or under Docker." 25 | echo -e "" 26 | echo -e "Env vars:" 27 | echo -e " MGPLAT_TOOLCHAIN_ROOT -> root directory of the toolchain" 28 | echo -e " MGPLAT_MG_ROOT -> root directory of memgraph" 29 | echo -e " MGPLAT_MG_TAG -> git ref/branch of memgraph to build" 30 | echo -e " MGPLAT_MG_BUILD_TYPE -> Debug|Release|RelWithDebInfo" 31 | echo -e " MGPLAT_CORES -> number of cores to build memgraph" 32 | echo -e "" 33 | echo -e "How to run?" 34 | echo -e " $0 [build|copy_binary|copy_package|cleanup]" 35 | exit 1 36 | } 37 | 38 | pull_memgraph_and_os() { 39 | cd "$MGPLAT_MG_ROOT" 40 | git checkout "$MGPLAT_MG_TAG" 41 | git pull origin "$MGPLAT_MG_TAG" 42 | # shellcheck disable=SC1091 43 | source "$MGPLAT_MG_ROOT/environment/util.sh" 44 | # Required to get the underlying opearting system 45 | OPERATING_SYSTEM_FAMILY="$(operating_system | cut -d "-" -f 1)" 46 | } 47 | 48 | build() { 49 | pull_memgraph_and_os 50 | if [ "$(architecture)" = "arm64" ] || [ "$(architecture)" = "aarch64" ]; then 51 | OS_SCRIPT="$MGPLAT_MG_ROOT/environment/os/$(operating_system)-arm.sh" 52 | else 53 | OS_SCRIPT="$MGPLAT_MG_ROOT/environment/os/$(operating_system).sh" 54 | fi 55 | if [ "$EUID" -eq 0 ]; then # sudo or root -> it should be possible to just install deps 56 | "$OS_SCRIPT" install TOOLCHAIN_RUN_DEPS 57 | "$OS_SCRIPT" install MEMGRAPH_BUILD_DEPS 58 | else # regular user -> privilege escalation required to install the system level deps 59 | sudo "$OS_SCRIPT" install TOOLCHAIN_RUN_DEPS 60 | sudo "$OS_SCRIPT" install MEMGRAPH_BUILD_DEPS 61 | fi 62 | # shellcheck disable=SC1091 63 | source "$MGPLAT_TOOLCHAIN_ROOT/activate" 64 | ./init 65 | mkdir -p build && cd build 66 | if [ "$(architecture)" = "arm64" ] || [ "$(architecture)" = "aarch64" ]; then 67 | cmake -DCMAKE_BUILD_TYPE="$MGPLAT_MG_BUILD_TYPE" -DMG_ARCH="ARM64" .. 68 | else 69 | cmake -DCMAKE_BUILD_TYPE="$MGPLAT_MG_BUILD_TYPE" .. 70 | fi 71 | make -j"$MGPLAT_CORES" && make -j"$MGPLAT_CORES" mgconsole 72 | mkdir -p output && cd output 73 | ${MGPLAT_CPACK[$OPERATING_SYSTEM_FAMILY]} 74 | } 75 | 76 | cleanup() { 77 | cd "$MGPLAT_MG_ROOT" 78 | rm -rf ./build/* 79 | ./libs/cleanup.sh 80 | } 81 | 82 | copy_binary() { 83 | if [ ! -f "$MGPLAT_MG_ROOT/build/memgraph" ]; then 84 | echo "Unable to find memgraph under the build folder" 85 | exit 1 86 | fi 87 | binary_name="$(basename $(readlink "$MGPLAT_MG_ROOT"/build/memgraph))" 88 | cp -L "$MGPLAT_MG_ROOT/build/memgraph" "$MGPLAT_DIST_BINARY/$binary_name" 89 | } 90 | 91 | copy_package() { 92 | # NOTE: dist/package is mounted -> root is required -> think about better way 93 | sudo cp "$MGPLAT_MG_ROOT"/build/output/memgraph* "$DIR/dist/package" 94 | } 95 | 96 | if [ "$#" == 0 ]; then 97 | # if we source this script to get access to the env vars. 98 | echo "NOTE: running $0 with 0 args -> pass" 99 | else 100 | case "$1" in 101 | build) 102 | build 103 | ;; 104 | copy_binary) 105 | copy_binary 106 | ;; 107 | copy_package) 108 | copy_package 109 | ;; 110 | cleanup) 111 | clean 112 | ;; 113 | *) 114 | print_help 115 | ;; 116 | esac 117 | fi 118 | -------------------------------------------------------------------------------- /scripts/docker_image_mage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 | 5 | MAGE_DIR="$DIR/../mage" 6 | print_help() { 7 | echo -e "Builds memgraph mage Docker image." 8 | echo -e "" 9 | echo -e "How to run?" 10 | echo -e " $0 [-h|build src_package_path image_name]" 11 | exit 1 12 | } 13 | 14 | build() { 15 | src_package="$1" 16 | image_name="$2" 17 | package_file="$(basename $src_package)" 18 | mage_package_file="memgraph-${package_file#memgraph_}" 19 | package_file_name="${package_file%.*}" 20 | target_arch="${package_file_name#memgraph_}" 21 | arch_suffix="${target_arch##*_}" 22 | cp "$src_package" \ 23 | "$MAGE_DIR/$mage_package_file" 24 | cd ${MAGE_DIR} 25 | docker buildx build --target prod --platform="linux/$arch_suffix" -t "$image_name" --build-arg TARGETARCH="$target_arch" -f "$MAGE_DIR/Dockerfile.release" . 26 | mkdir -p "$DIR/dist/docker" 27 | docker save ${image_name} | gzip -f > "$DIR/dist/docker/${image_name}.tar.gz" 28 | } 29 | 30 | if [ "$#" == 0 ]; then 31 | print_help 32 | else 33 | case "$1" in 34 | build) 35 | if [ "$#" -ne 3 ]; then 36 | print_help 37 | fi 38 | build "$2" "$3" 39 | ;; 40 | *) 41 | print_help 42 | ;; 43 | esac 44 | fi 45 | -------------------------------------------------------------------------------- /scripts/docker_image_memgraph.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 | 5 | MEMGRAPH_DOCKER_DIR="$DIR/../mage/cpp/memgraph/release/docker" 6 | print_help() { 7 | echo -e "Builds memgraph Docker image." 8 | echo -e "" 9 | echo -e "How to run?" 10 | echo -e " $0 [-h|build src_package_path]" 11 | exit 1 12 | } 13 | 14 | build() { 15 | src_package="$1" 16 | package_file="$(basename $src_package)" 17 | package_file_no_prefix="${package_file#memgraph_}" 18 | memgraph_version="${package_file_no_prefix%-1*}" 19 | dockerize_memgraph_version="$(echo "$memgraph_version" | sed 's/+/_/g' | sed 's/~/_/g')" 20 | $MEMGRAPH_DOCKER_DIR/package_docker "$src_package" 21 | mkdir -p "$DIR/dist/docker" 22 | cp "$MEMGRAPH_DOCKER_DIR/memgraph-${dockerize_memgraph_version}-docker.tar.gz" "$DIR/dist/docker" 23 | } 24 | 25 | if [ "$#" == 0 ]; then 26 | print_help 27 | else 28 | case "$1" in 29 | build) 30 | if [ "$#" -ne 2 ]; then 31 | print_help 32 | fi 33 | build "$2" 34 | ;; 35 | *) 36 | print_help 37 | ;; 38 | esac 39 | fi 40 | -------------------------------------------------------------------------------- /scripts/docker_image_platform.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 | 5 | MGPLAT_ROOT="$DIR/../" 6 | MGPLAT_GHA_PAT_TOKEN="${MGPLAT_GHA_PAT_TOKEN:-github_personal_access_token}" 7 | print_help() { 8 | echo -e "Builds memgraph platform Docker image." 9 | echo -e "" 10 | echo -e "Env vars:" 11 | echo -e " MGPLAT_GHA_PAT_TOKEN -> Github PAT token to download Lab's NPM package" 12 | echo -e "" 13 | echo -e "How to run?" 14 | echo -e " $0 [-h|build src_package_path image_name]" 15 | exit 1 16 | } 17 | 18 | # TODO(gitbuda): An option to build wihout mage. 19 | build() { 20 | src_package="$1" 21 | image_name="$2" 22 | package_file="$(basename $src_package)" 23 | platform_package_file="memgraph-${package_file#memgraph_}" 24 | package_file_name="${package_file%.*}" 25 | target_arch="${package_file_name#memgraph_}" 26 | arch_suffix="${target_arch##*_}" 27 | cp "$src_package" \ 28 | "$MGPLAT_ROOT/$platform_package_file" 29 | cd "$MGPLAT_ROOT" 30 | docker buildx build --platform="linux/$arch_suffix" -t ${image_name} \ 31 | --build-arg TARGETARCH="$target_arch" \ 32 | --build-arg NPM_PACKAGE_TOKEN="${MGPLAT_GHA_PAT_TOKEN}" \ 33 | -f Dockerfile . 34 | mkdir -p "$DIR/dist/docker" 35 | docker save ${image_name} | gzip -f > "$DIR/dist/docker/${image_name}.tar.gz" 36 | } 37 | 38 | if [ "$#" == 0 ]; then 39 | print_help 40 | else 41 | case "$1" in 42 | build) 43 | if [ "$#" -ne 3 ]; then 44 | print_help 45 | fi 46 | build "$2" "$3" 47 | ;; 48 | *) 49 | print_help 50 | ;; 51 | esac 52 | fi 53 | -------------------------------------------------------------------------------- /scripts/pack_memgraph_via_docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 | 5 | # NOTE: The builder container image defines for which operating system Memgraph will be built. 6 | MGPLAT_CNT_IMAGE="${MGPLAT_CNT_IMAGE:-memgraph/memgraph-builder:v4_debian-10}" 7 | MGPLAT_CNT_NAME="${MGPLAT_CNT_NAME:-mgbuild_builder}" 8 | MGPLAT_CNT_MG_ROOT="${MGPLAT_CNT_MG_ROOT:-/platform/mage/cpp/memgraph}" 9 | MGPLAT_MG_TAG="${MGPLAT_MG_TAG:-master}" 10 | MGPLAT_MG_BUILD_TYPE="${MGPLAT_MG_BUILD_TYPE:-RelWithDebInfo}" 11 | MGPLAT_DIST_BINARY="$DIR/dist/binary" 12 | print_help() { 13 | echo -e "Builds memgraph binary and package via Docker build container." 14 | echo -e "" 15 | echo -e "Env vars:" 16 | echo -e " MGPLAT_CNT_IMAGE -> Docker image used to build and pack memgraph" 17 | echo -e " MGPLAT_CNT_NAME -> the name of builder Docker container" 18 | echo -e " MGPLAT_CNT_MG_ROOT -> memgraph root directory inside the container" 19 | echo -e " MGPLAT_MG_TAG -> git ref/branch of memgraph to build" 20 | echo -e " MGPLAT_MG_BUILD_TYPE -> Debug|Release|RelWithDebInfo" 21 | echo -e "" 22 | echo -e "How to run?" 23 | echo -e " $0 [pack|cleanup|copy_binary]" 24 | exit 1 25 | } 26 | 27 | docker_run () { 28 | cnt_name="$1" 29 | cnt_image="$2" 30 | if [ ! "$(docker ps -q -f name="$cnt_name")" ]; then 31 | if [ "$(docker ps -aq -f status=exited -f name="$cnt_name")" ]; then 32 | echo "Cleanup of the old exited container..." 33 | docker rm "$cnt_name" 34 | fi 35 | docker run -d \ 36 | -v "$DIR/..:/platform" \ 37 | -v "$DIR/dist/package:$MGPLAT_CNT_MG_ROOT/build/output" \ 38 | --network host --name "$cnt_name" "$cnt_image" 39 | fi 40 | echo "The $cnt_image container is active under $cnt_name name!" 41 | } 42 | 43 | docker_stop_rm() { 44 | docker stop "$MGPLAT_CNT_NAME" 45 | docker rm "$MGPLAT_CNT_NAME" 46 | } 47 | 48 | docker_exec() { 49 | cnt_cmd="$1" 50 | docker exec -it "$MGPLAT_CNT_NAME" bash -c "$cnt_cmd" 51 | } 52 | 53 | build_pack() { 54 | cd "$DIR" 55 | # shellcheck disable=SC1091 56 | source build_memgraph_native.sh 57 | mkdir -p dist/binary 58 | docker_run "$MGPLAT_CNT_NAME" "$MGPLAT_CNT_IMAGE" 59 | docker cp "$DIR/build_memgraph_native.sh" "$MGPLAT_CNT_NAME:/" 60 | docker_exec "git config --global --add safe.directory $MGPLAT_CNT_MG_ROOT" 61 | mg_root="MGPLAT_MG_ROOT=$MGPLAT_CNT_MG_ROOT" 62 | mg_tag="MGPLAT_MG_TAG=$MGPLAT_MG_TAG" 63 | mg_build_type="MGPLAT_MG_BUILD_TYPE=$MGPLAT_MG_BUILD_TYPE" 64 | docker_exec "$mg_root $mg_build_type $mg_tag /build_memgraph_native.sh build" 65 | } 66 | 67 | cleanup() { 68 | docker_exec "rm -rf $MGPLAT_CNT_MG_ROOT/build/*" 69 | docker_exec "$MGPLAT_CNT_MG_ROOT/libs/cleanup.sh" 70 | } 71 | 72 | copy_binary() { 73 | cnt_cmd="echo \$(readlink $MGPLAT_CNT_MG_ROOT/build/memgraph)" 74 | cnt_binary_path=$(docker exec "$MGPLAT_CNT_NAME" bash -c "$cnt_cmd") 75 | binary_name="$(basename $cnt_binary_path)" 76 | src_cnt_binary_path="$MGPLAT_CNT_NAME:$cnt_binary_path" 77 | docker cp -L "$src_cnt_binary_path" "$DIR/dist/binary/" 78 | } 79 | 80 | if [ "$#" == 0 ]; then 81 | build_pack 82 | else 83 | case "$1" in 84 | pack) 85 | build_pack 86 | ;; 87 | # NOTE: The output package might be deleted as well (from our mounted dir). 88 | cleanup) 89 | cleanup 90 | ;; 91 | # Useful if you need memgraph binary for a specific operating system, e.g. 92 | # Debian 10 binary to run under Jepsen 93 | copy_binary) 94 | copy_binary 95 | ;; 96 | *) 97 | print_help 98 | ;; 99 | esac 100 | fi 101 | -------------------------------------------------------------------------------- /tools/remove_docker_tag.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | USERNAME="${1}" 6 | PASSWORD="${2}" 7 | ORGANIZATION="${3}" 8 | IMAGE="${4}" 9 | TAG="${5}" 10 | 11 | function login_data() { 12 | cat <