From 674fb6ff579e1c462a482fb145ecdce26b337ecd Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 20 Dec 2024 20:33:12 -0600 Subject: [PATCH 1/3] Update Docker instructions in support of #1930 Updates README.DOCKER.md and Dockerfile --- Dockerfile | 1 + README.DOCKER.md | 111 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 104 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 84652fbf9..317625f42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ WORKDIR /usr/src/app # Copy package.json into the image, then run yarn install # This improves caching so we don't have to download the dependencies every time the code changes COPY package.json ./ +COPY config/default.json config/default.json # --ignore-scripts tells yarn not to run postbuild. We run it explicitly later RUN npm install --ignore-scripts diff --git a/README.DOCKER.md b/README.DOCKER.md index 356ac398a..ca8e7c864 100644 --- a/README.DOCKER.md +++ b/README.DOCKER.md @@ -1,12 +1,107 @@ -# Running Homebrewery via Docker +# Offline Install Instructions: Docker -The repo includes a Dockerfile and a docker-compose.yml file. + These instructions are for setting up a persistent instance of the Homebrewery application locally using Docker. + + If you intend to develop with Homebrewery, following the Homebrewery application section of this guide is not recommended. Using docker to deploy MongoDB locally for development is not a bad idea at all, however. + + # Install Docker -To run the application via docker-compose.yml: -`docker-compose up -d` + ## Docker Desktop (MacOS/Windows) + + Windows and Mac installs use Docker Desktop. Current install instructions are below. + + * [Mac](https://docs.docker.com/desktop/mac/install/) + * [Windows](https://docs.docker.com/desktop/windows/install/) + + You can set up the docker engine to start on boot via the Docker desktop UI. + + ## Docker Engine -To stop the application: -`docker-compose down` + Linux installs use Docker Engine. Docker provides installers and instructions for several of the most common distrubutions. If you do not see yours listed, it is very likely supported indirectly by your distribution. + + * [Arch](https://docs.docker.com/desktop/setup/install/linux/archlinux/) + * [CentOS](https://docs.docker.com/engine/install/centos/) + * [Debian](https://docs.docker.com/engine/install/debian/) + * [Fedora](https://docs.docker.com/engine/install/fedora/) + * [RHEL](https://docs.docker.com/engine/install/rhel/) + * [Ubuntu](https://docs.docker.com/engine/install/ubuntu/) + + ### Post installation steps + [Manage Docker as a non-root user (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) + [Enable Docker to start on boot (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot) + + # Build Homebrewery Image + +Next we build the homebrewery docker image. Start by cloning the repository. + + ```shell + git clone https://github.com/naturalcrit/homebrewery.git + cd homebrewery + ``` + + Make an changes you need to `config/default.json` then build the image. + + ```shell + docker-compose build homebrewery + ``` + + # Add Mongo container + + Once docker is installed and running, it is time to set up the containers. First up, Mongo. + + ```shell + docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 mongo:latest + ``` + + Older CPUs may run into an issue with AVX support. + ``` + WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that! + see https://jira.mongodb.org/browse/SERVER-54407 + see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2 + see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814 +``` +If you see a message similar to this, try using the bitnami mongo instead. + +```shell +docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 bitnami/mongo:latest +``` + + If your distribution is running on an arm device such as a Raspberry Pi, you will need to run the arm-built MongoDB v4.4. + +```shell +docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 arm64v8/mongo:4.4 +``` + + ## Run the Homebrewery Image + ```shell + # Make sure you run this in the homebrewery directory + docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest + ``` + + ## Updating the Image + +When Homebrewery code updates, your docker container will not automatically follow the changes. To do so you will need to rebuild your homebrewery image. + +First, return to your homebrewery clone (from Build Homebrewery Image above) or recreate the clone if you deleted your copy of the code. + +First, delete the existing image. + + ```shell + docker rm -f homebrewery-app + ``` + + Next, update the clone's code to the latest version. + + ```shell + cd homebrewery + git checkout master + git pull upstream master + ``` + + Finally, rebuild and restart the homebrewery image. + + ```shell + docker-compose build homebrewery + docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest + ``` -To stop the application and remove all data: -`docker-compose down -v` From 2bedc6d7d4b3c0c94e8be43f2cdd91de4a3dfd8a Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 20 Dec 2024 21:30:19 -0600 Subject: [PATCH 2/3] Updates to docker files and cooresponding documentation. --- Dockerfile | 6 +- README.DOCKER.md | 164 ++++++++++++++++++++++++--------------------- docker-compose.yml | 1 - 3 files changed, 92 insertions(+), 79 deletions(-) diff --git a/Dockerfile b/Dockerfile index 317625f42..17d02b01f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine +FROM node:22-alpine RUN apk --no-cache add git ENV NODE_ENV=docker @@ -9,8 +9,10 @@ WORKDIR /usr/src/app # Copy package.json into the image, then run yarn install # This improves caching so we don't have to download the dependencies every time the code changes COPY package.json ./ -COPY config/default.json config/default.json +COPY config/docker.json usr/src/app/config # --ignore-scripts tells yarn not to run postbuild. We run it explicitly later +RUN node --version +RUN npm --version RUN npm install --ignore-scripts # Bundle app source and build application diff --git a/README.DOCKER.md b/README.DOCKER.md index ca8e7c864..ee2d0bb2f 100644 --- a/README.DOCKER.md +++ b/README.DOCKER.md @@ -1,107 +1,119 @@ # Offline Install Instructions: Docker - These instructions are for setting up a persistent instance of the Homebrewery application locally using Docker. - - If you intend to develop with Homebrewery, following the Homebrewery application section of this guide is not recommended. Using docker to deploy MongoDB locally for development is not a bad idea at all, however. - - # Install Docker +These instructions are for setting up a persistent instance of the Homebrewery application locally using Docker. - ## Docker Desktop (MacOS/Windows) - - Windows and Mac installs use Docker Desktop. Current install instructions are below. - - * [Mac](https://docs.docker.com/desktop/mac/install/) - * [Windows](https://docs.docker.com/desktop/windows/install/) - - You can set up the docker engine to start on boot via the Docker desktop UI. - - ## Docker Engine +If you intend to develop with Homebrewery, following the Homebrewery application section of this guide is not recommended. Using docker to deploy MongoDB locally for development is not a bad idea at all, however. - Linux installs use Docker Engine. Docker provides installers and instructions for several of the most common distrubutions. If you do not see yours listed, it is very likely supported indirectly by your distribution. +# Install Docker - * [Arch](https://docs.docker.com/desktop/setup/install/linux/archlinux/) - * [CentOS](https://docs.docker.com/engine/install/centos/) - * [Debian](https://docs.docker.com/engine/install/debian/) - * [Fedora](https://docs.docker.com/engine/install/fedora/) - * [RHEL](https://docs.docker.com/engine/install/rhel/) - * [Ubuntu](https://docs.docker.com/engine/install/ubuntu/) - - ### Post installation steps - [Manage Docker as a non-root user (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) - [Enable Docker to start on boot (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot) - - # Build Homebrewery Image +## Docker Desktop (MacOS/Windows) + +Windows and Mac installs use Docker Desktop. Current install instructions are below. + +* [Mac](https://docs.docker.com/desktop/mac/install/) +* [Windows](https://docs.docker.com/desktop/windows/install/) + +You can set up the docker engine to start on boot via the Docker desktop UI. + +## Docker Engine + +Linux installs use Docker Engine. Docker provides installers and instructions for several of the most common distrubutions. If you do not see yours listed, it is very likely supported indirectly by your distribution. + +* [Arch](https://docs.docker.com/desktop/setup/install/linux/archlinux/) +* [CentOS](https://docs.docker.com/engine/install/centos/) +* [Debian](https://docs.docker.com/engine/install/debian/) +* [Fedora](https://docs.docker.com/engine/install/fedora/) +* [RHEL](https://docs.docker.com/engine/install/rhel/) + * [Ubuntu](https://docs.docker.com/engine/install/ubuntu/) + +### Post installation steps +[Manage Docker as a non-root user (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) +[Enable Docker to start on boot (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot) + +# Build Homebrewery Image Next we build the homebrewery docker image. Start by cloning the repository. - ```shell - git clone https://github.com/naturalcrit/homebrewery.git - cd homebrewery - ``` +```shell +git clone https://github.com/naturalcrit/homebrewery.git +cd homebrewery +``` - Make an changes you need to `config/default.json` then build the image. +Make an changes you need to `config/docker.json` then build the image. If it does not exist,the below as a template. - ```shell - docker-compose build homebrewery - ``` - - # Add Mongo container +``` +{ +"host" : "localhost:8000", +"naturalcrit_url" : "local.naturalcrit.com:8010", +"secret" : "secret", +"web_port" : 8000, +"enable_v3" : true, +"mongodb_uri": "mongodb://172.17.0.2/homebrewery", +"enable_themes" : true, +} +``` - Once docker is installed and running, it is time to set up the containers. First up, Mongo. +```shell +docker-compose build homebrewery +``` - ```shell - docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 mongo:latest - ``` +# Add Mongo container - Older CPUs may run into an issue with AVX support. - ``` - WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that! - see https://jira.mongodb.org/browse/SERVER-54407 - see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2 - see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814 +Once docker is installed and running, it is time to set up the containers. First up, Mongo. + +```shell +docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 mongo:latest +``` + +Older CPUs may run into an issue with AVX support. +``` +WARNING: MongoDB 5.0+ requires a CPU with AVX support, and your current system does not appear to have that! + see https://jira.mongodb.org/browse/SERVER-54407 + see also https://www.mongodb.com/community/forums/t/mongodb-5-0-cpu-intel-g4650-compatibility/116610/2 + see also https://github.com/docker-library/mongo/issues/485#issuecomment-891991814 ``` If you see a message similar to this, try using the bitnami mongo instead. ```shell docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 bitnami/mongo:latest ``` - - If your distribution is running on an arm device such as a Raspberry Pi, you will need to run the arm-built MongoDB v4.4. - + +If your distribution is running on an arm device such as a Raspberry Pi, you will need to run the arm-built MongoDB v4.4. + ```shell docker run --name homebrewery-mongodb -d --restart unless-stopped -v mongodata:/data/db -p 27017:27017 arm64v8/mongo:4.4 ``` - - ## Run the Homebrewery Image - ```shell - # Make sure you run this in the homebrewery directory - docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest - ``` - - ## Updating the Image - + +## Run the Homebrewery Image +```shell +# Make sure you run this in the homebrewery directory +docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest +``` + +## Updating the Image + When Homebrewery code updates, your docker container will not automatically follow the changes. To do so you will need to rebuild your homebrewery image. First, return to your homebrewery clone (from Build Homebrewery Image above) or recreate the clone if you deleted your copy of the code. First, delete the existing image. - - ```shell - docker rm -f homebrewery-app - ``` - Next, update the clone's code to the latest version. +```shell +docker rm -f homebrewery-app +``` - ```shell - cd homebrewery - git checkout master - git pull upstream master - ``` +Next, update the clone's code to the latest version. - Finally, rebuild and restart the homebrewery image. - - ```shell - docker-compose build homebrewery - docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest - ``` +```shell +cd homebrewery +git checkout master +git pull upstream master +``` + +Finally, rebuild and restart the homebrewery image. + +```shell +docker-compose build homebrewery +docker run --name homebrewery-app -d --restart unless-stopped -e NODE_ENV=docker -v $(pwd)/config/docker.json:/usr/src/app/config/docker.json -p 8000:8000 docker.io/library/homebrewery:latest +``` diff --git a/docker-compose.yml b/docker-compose.yml index f74fadc0a..d7e5f3b90 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '2' services: mongodb: image: mongo:latest From e9b5e4ab0c9335ea169fe21ba1d9314e77ac9a37 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 5 Jan 2025 15:04:55 -0500 Subject: [PATCH 3/3] indent --- README.DOCKER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.DOCKER.md b/README.DOCKER.md index ee2d0bb2f..4dfbef045 100644 --- a/README.DOCKER.md +++ b/README.DOCKER.md @@ -24,7 +24,7 @@ Linux installs use Docker Engine. Docker provides installers and instructions fo * [Debian](https://docs.docker.com/engine/install/debian/) * [Fedora](https://docs.docker.com/engine/install/fedora/) * [RHEL](https://docs.docker.com/engine/install/rhel/) - * [Ubuntu](https://docs.docker.com/engine/install/ubuntu/) +* [Ubuntu](https://docs.docker.com/engine/install/ubuntu/) ### Post installation steps [Manage Docker as a non-root user (highly recommended)](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)