From ff5c7d33398fd3b9bec8cae8859c302f3b9ca459 Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 15:50:52 -0500 Subject: [PATCH 01/18] testing github actions --- .github/workflows/deploy-images.yml | 48 +++++++++++++++++++++++++++++ .gitignore | 3 -- 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy-images.yml diff --git a/.github/workflows/deploy-images.yml b/.github/workflows/deploy-images.yml new file mode 100644 index 0000000..f98c4d9 --- /dev/null +++ b/.github/workflows/deploy-images.yml @@ -0,0 +1,48 @@ +# +name: Create and publish a Docker image + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + push: + branches: ['main'] + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + # + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index eb7f69c..14afc83 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,3 @@ serviceAccount.json #VSCODE Preferences .vscode -# personal containers -/.devcontainer/** -.github \ No newline at end of file From a0355b053d37e1922bee3047d90bbc92fbb2d498 Mon Sep 17 00:00:00 2001 From: abdullah abbas <46547131+abdullahalhoothy@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:55:17 -0500 Subject: [PATCH 02/18] Update deploy-images.yml --- .github/workflows/deploy-images.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-images.yml b/.github/workflows/deploy-images.yml index f98c4d9..1687ccc 100644 --- a/.github/workflows/deploy-images.yml +++ b/.github/workflows/deploy-images.yml @@ -42,7 +42,8 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: - context: . + context: ./docker_image_build_files + file: ./docker_image_build_files/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} From dce2db9f999f99509214218de52fb5f609a12413 Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 16:02:21 -0500 Subject: [PATCH 03/18] updated dockerfile to seperate some commands --- docker_image_build_files/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 24e873b..acafc14 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -54,8 +54,8 @@ ENV GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/ ENV CYPRESS_INSTALL_BINARY=0 # Use a RUN command to export the environment variables -RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" && \ - npm install && \ +RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" +RUN npm install && \ cd /home/user/projects/baby-equipment-exchange/functions && \ npm install && \ npm run build && \ From 6b51a4fe658a5d7ba2aa657aca4dfb30ccb7ec5a Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 16:08:56 -0500 Subject: [PATCH 04/18] fixing docker issue --- docker_image_build_files/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index acafc14..1ae1103 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -60,8 +60,8 @@ RUN npm install && \ npm install && \ npm run build && \ cd /home/user/projects/baby-equipment-exchange && \ - npm run build && \ - firebase experiments:enable webframeworks + npm run build +RUN firebase experiments:enable webframeworks # Define a volume in the image, this is to be passed from terraform From 6f3c741c15cdebdeee698f4d146d35af7ce5139b Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 16:19:57 -0500 Subject: [PATCH 05/18] separated more --- docker_image_build_files/Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 1ae1103..745db08 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -55,11 +55,13 @@ ENV CYPRESS_INSTALL_BINARY=0 # Use a RUN command to export the environment variables RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" -RUN npm install && \ - cd /home/user/projects/baby-equipment-exchange/functions && \ +RUN npm install + +RUN cd /home/user/projects/baby-equipment-exchange/functions && \ npm install && \ - npm run build && \ - cd /home/user/projects/baby-equipment-exchange && \ + npm run build + +RUN cd /home/user/projects/baby-equipment-exchange && \ npm run build RUN firebase experiments:enable webframeworks From bb00c4629b8321cc786acc9d225a8c439b8ae3e7 Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 16:28:21 -0500 Subject: [PATCH 06/18] isolating issue --- docker_image_build_files/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 745db08..0a65ef1 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -61,8 +61,8 @@ RUN cd /home/user/projects/baby-equipment-exchange/functions && \ npm install && \ npm run build -RUN cd /home/user/projects/baby-equipment-exchange && \ - npm run build +RUN cd /home/user/projects/baby-equipment-exchange +RUN npm run build RUN firebase experiments:enable webframeworks From 6ea9346cf8085a71f44d65bc96e3b61597389ff7 Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 16:56:16 -0500 Subject: [PATCH 07/18] test secrets --- .github/workflows/deploy-images.yml | 3 +++ docker_image_build_files/Dockerfile | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-images.yml b/.github/workflows/deploy-images.yml index 1687ccc..2663711 100644 --- a/.github/workflows/deploy-images.yml +++ b/.github/workflows/deploy-images.yml @@ -47,3 +47,6 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + FIREBASE_CONFIG_BASE64=${{secrets.FIREBASE_CONFIG_BASE64}} + SERVICE_ACCOUNT_BASE64=${{secrets.SERVICE_ACCOUNT_BASE64}} \ No newline at end of file diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 0a65ef1..a62b9ef 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -42,6 +42,14 @@ ARG FIREBASE_CONFIG ENV FIREBASE_CONFIG=$FIREBASE_CONFIG RUN chmod +x /home/user/projects/baby-equipment-exchange/ +# Accept build-time variables +ARG FIREBASE_CONFIG_BASE64 +ARG SERVICE_ACCOUNT_BASE64 + +# Use a RUN command to create the files from the arguments +RUN echo "$FIREBASE_CONFIG_BASE64" | base64 -d > /home/user/projects/baby-equipment-exchange/firebaseConfig.json +RUN echo "$SERVICE_ACCOUNT_BASE64" | base64 -d > /home/user/projects/baby-equipment-exchange/serviceAccount.json + RUN npm install -g firebase-tools RUN touch /home/user/projects/baby-equipment-exchange/.env.local @@ -54,16 +62,14 @@ ENV GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/ ENV CYPRESS_INSTALL_BINARY=0 # Use a RUN command to export the environment variables -RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" -RUN npm install - -RUN cd /home/user/projects/baby-equipment-exchange/functions && \ +RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" && \ npm install && \ - npm run build - -RUN cd /home/user/projects/baby-equipment-exchange -RUN npm run build -RUN firebase experiments:enable webframeworks + cd /home/user/projects/baby-equipment-exchange/functions && \ + npm install && \ + npm run build && \ + cd /home/user/projects/baby-equipment-exchange && \ + npm run build && \ + firebase experiments:enable webframeworks # Define a volume in the image, this is to be passed from terraform From 64b08004189b247dcdf34b2b32f4a18081f7280e Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 19:15:21 -0500 Subject: [PATCH 08/18] updating dockerfile to use github secrets --- docker_image_build_files/Dockerfile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index a62b9ef..be3166f 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -6,6 +6,15 @@ RUN apt-get update && \ apt-get install -y git default-jdk jq && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +RUN wget https://chromedriver.storage.googleapis.com/94.0.4606.61/chromedriver_linux64.zip && \ + unzip chromedriver_linux64.zip && \ + mv chromedriver /usr/bin/chromedriver && \ + chmod +x /usr/bin/chromedriver && \ + rm -f chromedriver_linux64.zip +RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \ + dpkg -i google-chrome-stable_current_amd64.deb || true && \ + apt-get install -f -y && \ + rm -f google-chrome-stable_current_amd64.deb RUN mkdir -p /home/user/projects/ WORKDIR /home/user/projects/ @@ -21,17 +30,10 @@ WORKDIR ${REPO_DIR} RUN git checkout main -RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \ - dpkg -i google-chrome-stable_current_amd64.deb || true && \ - apt-get install -f -y && \ - rm -f google-chrome-stable_current_amd64.deb + # the below envinroment variables should be passed through terraform ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome -RUN wget https://chromedriver.storage.googleapis.com/94.0.4606.61/chromedriver_linux64.zip && \ - unzip chromedriver_linux64.zip && \ - mv chromedriver /usr/bin/chromedriver && \ - chmod +x /usr/bin/chromedriver && \ - rm -f chromedriver_linux64.zip + # in the future the below files need to be passed through terraform # at the moment the json files must be in the same directory as the dockerfile # Copy all JSON files from the Dockerfile's directory to the specified working directory in the Docker image @@ -45,7 +47,6 @@ RUN chmod +x /home/user/projects/baby-equipment-exchange/ # Accept build-time variables ARG FIREBASE_CONFIG_BASE64 ARG SERVICE_ACCOUNT_BASE64 - # Use a RUN command to create the files from the arguments RUN echo "$FIREBASE_CONFIG_BASE64" | base64 -d > /home/user/projects/baby-equipment-exchange/firebaseConfig.json RUN echo "$SERVICE_ACCOUNT_BASE64" | base64 -d > /home/user/projects/baby-equipment-exchange/serviceAccount.json @@ -62,14 +63,15 @@ ENV GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/ ENV CYPRESS_INSTALL_BINARY=0 # Use a RUN command to export the environment variables -RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" && \ +RUN export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json | jq -c .)" && \ npm install && \ cd /home/user/projects/baby-equipment-exchange/functions && \ npm install && \ npm run build && \ cd /home/user/projects/baby-equipment-exchange && \ - npm run build && \ - firebase experiments:enable webframeworks + firebase experiments:enable webframeworks && \ + npm run build + # Define a volume in the image, this is to be passed from terraform From 330abb1187e72f9e54723c3592d10fe7d62fb2ae Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 19:24:04 -0500 Subject: [PATCH 09/18] added shatags to images --- .github/workflows/deploy-images.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-images.yml b/.github/workflows/deploy-images.yml index 2663711..a1d9135 100644 --- a/.github/workflows/deploy-images.yml +++ b/.github/workflows/deploy-images.yml @@ -36,6 +36,9 @@ jobs: uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. From ae14bbef0c94850050e0f9306fb0fe8c9a337db3 Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 19:46:58 -0500 Subject: [PATCH 10/18] added latest tag and updated readme --- .github/workflows/deploy-images.yml | 1 + README.md | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.github/workflows/deploy-images.yml b/.github/workflows/deploy-images.yml index a1d9135..0684c5a 100644 --- a/.github/workflows/deploy-images.yml +++ b/.github/workflows/deploy-images.yml @@ -39,6 +39,7 @@ jobs: tags: | type=ref,event=branch type=sha + latest # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. diff --git a/README.md b/README.md index 038f06f..be99afd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,26 @@ This project assists the collection and distribution of unused and gently used b ## Dev remote Setup (Recommended for consistency, you can dev local if you don't want to work with docker) 1. install Docker desktop (or equivalent in Mac and Linux) + +2. the Docker image is hosted in a the GitHub Packages repository, you'll need to authenticate with GitHub Packages to pull and run the image.you need to authenticate using a GitHub Personal Access Token (PAT) with at least read:packages permission. If you haven't already, generate a PAT by following these steps: +- Go to GitHub and log in. +- Click on your profile picture in the top right corner and go to Settings. +- On the left sidebar, click Developer settings. +- Click on Personal access tokens and then Generate new token. +- Give your token a name, set the expiration, and select at least the read:packages scope under package permissions. - If you also want to push or delete packages, select the appropriate additional scopes. +- Click Generate token at the bottom of the page and make sure to copy your new personal access token; you won't be able to see it again. +3. Log in to GitHub Packages +Use the docker login command to authenticate with GitHub Packages, replacing USERNAME with your GitHub username and TOKEN with the PAT you just created: +``` +export CR_PAT="ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +echo $CR_PAT | docker login ghcr.io -u codeforbtv --password-stdin +``` +4. Now that you're authenticated, you can pull and run the Docker image +``` +docker pull ghcr.io/codeforbtv/baby-equipment-exchange:latest +``` + + 2. download folder "docker_image_build_files" from the repo, it's better not to clone the entire repo because you will not develop on this cloned repo 3. you still need 2 additional files to authernticate locally contact the repo admin to get them, you need "firebaseConfig.json" and "serviceAccount.json", after you acquire them put those 2 files inside the "/docker_image_build_files/firebase_emulator_files/" 4. install visual studio code. From 15e54a0178d98356d9c8955004331ada8f01d5de Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 20:43:51 -0500 Subject: [PATCH 11/18] updated readme --- README.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index be99afd..d407cd7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This project assists the collection and distribution of unused and gently used b - Give your token a name, set the expiration, and select at least the read:packages scope under package permissions. - If you also want to push or delete packages, select the appropriate additional scopes. - Click Generate token at the bottom of the page and make sure to copy your new personal access token; you won't be able to see it again. 3. Log in to GitHub Packages -Use the docker login command to authenticate with GitHub Packages, replacing USERNAME with your GitHub username and TOKEN with the PAT you just created: +Use the docker login command to authenticate with GitHub Packages, use the PAT you just created for CR_PAT: ``` export CR_PAT="ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" echo $CR_PAT | docker login ghcr.io -u codeforbtv --password-stdin @@ -25,20 +25,12 @@ echo $CR_PAT | docker login ghcr.io -u codeforbtv --password-stdin ``` docker pull ghcr.io/codeforbtv/baby-equipment-exchange:latest ``` - - -2. download folder "docker_image_build_files" from the repo, it's better not to clone the entire repo because you will not develop on this cloned repo -3. you still need 2 additional files to authernticate locally contact the repo admin to get them, you need "firebaseConfig.json" and "serviceAccount.json", after you acquire them put those 2 files inside the "/docker_image_build_files/firebase_emulator_files/" -4. install visual studio code. -5. run visual studio code and install Visual Studio Code Dev Containers extension, for documentation on this extension (https://code.visualstudio.com/docs/devcontainers/containers) -6. open a terminal, navigate to "/docker_image_build_files/" and run the below lines to build a docker image (if we find a way to secure some of the json files we can just share the docker image) -``` -docker build -t babyequipments:1.01 . -``` -7. run the below to run a docker container +5. run the docker container ``` -docker run -dit -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 4400:4400 -p 4500:4500 -p 9099:9099 -p 8080:8080 -p 9150:9150 -p 9199:9199 --name baby-equipment-app babyequipments:1.01 +docker run -dit -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 4400:4400 -p 4500:4500 -p 9099:9099 -p 8080:8080 -p 9150:9150 -p 9199:9199 --name baby-equipment-app ghcr.io/abdullahalhoothy/baby-equipment-exchange:latest ``` +6. install visual studio code. +7. run visual studio code and install Visual Studio Code Dev Containers extension, for documentation on this extension (https://code.visualstudio.com/docs/devcontainers/containers) 8. Download VScode extension called "Remote Development" 9. in visual studio code press ctrl+shit+p to open command palette and select Dev Containers: Attach to Running Container (https://code.visualstudio.com/docs/devcontainers/attach-container) 10. select the Attach to Container inline action on the container you want to connect to @@ -54,6 +46,9 @@ npm run dev 14. see the output you can run in your host machine browser http://localhost:3000 + + + ## Dev Local Setup Below are linux command used to setup the environment. notes for setup on Mac are in `docs\setup_notes.md` From 9e63fb3768911dadeef33dde4344393e0be3fe5b Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 21:24:17 -0500 Subject: [PATCH 12/18] added make data_directory --- docker_image_build_files/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index be3166f..01b2a6a 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -28,7 +28,7 @@ ARG REPO_DIR="/home/user/projects/baby-equipment-exchange" RUN git clone ${GITHUB_REPO} WORKDIR ${REPO_DIR} RUN git checkout main - +RUN mkdir -p data_directory # the below envinroment variables should be passed through terraform From e6967939ae5c4f1b734bee3fb7399d73736ea32e Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 21:27:58 -0500 Subject: [PATCH 13/18] updated docker with full directory path --- docker_image_build_files/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 01b2a6a..01360c1 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -28,7 +28,7 @@ ARG REPO_DIR="/home/user/projects/baby-equipment-exchange" RUN git clone ${GITHUB_REPO} WORKDIR ${REPO_DIR} RUN git checkout main -RUN mkdir -p data_directory +RUN mkdir -p /home/user/projects/baby-equipment-exchange/data_directory/ # the below envinroment variables should be passed through terraform From cac05664585c667c844140a457a4e115ec27e91c Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 21:31:38 -0500 Subject: [PATCH 14/18] updated docker with full directory path --- docker_image_build_files/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 01360c1..7ba2a1b 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -56,9 +56,9 @@ RUN npm install -g firebase-tools RUN touch /home/user/projects/baby-equipment-exchange/.env.local # the below envinroment variables should be passed through terraform RUN echo 'GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/serviceAccount.json"' >> /home/user/projects/baby-equipment-exchange/.env.local -RUN echo 'FIREBASE_EMULATORS_IMPORT_DIRECTORY="./data_directory"' >> /home/user/projects/baby-equipment-exchange/.env.local +RUN echo 'FIREBASE_EMULATORS_IMPORT_DIRECTORY="/home/user/projects/baby-equipment-exchange/data_directory/"' >> /home/user/projects/baby-equipment-exchange/.env.local RUN echo FIREBASE_CONFIG=\"$(jq -c . < firebaseConfig.json)\" >> .env.local -ENV FIREBASE_EMULATORS_IMPORT_DIRECTORY="./data_directory" +ENV FIREBASE_EMULATORS_IMPORT_DIRECTORY="/home/user/projects/baby-equipment-exchange/data_directory/" ENV GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/serviceAccount.json" ENV CYPRESS_INSTALL_BINARY=0 From 95ec8ed92db562e14be6bb60eda72ea540c5b9fa Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 21:38:32 -0500 Subject: [PATCH 15/18] removed service account from dockerfile --- docker_image_build_files/Dockerfile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docker_image_build_files/Dockerfile b/docker_image_build_files/Dockerfile index 7ba2a1b..bf13777 100644 --- a/docker_image_build_files/Dockerfile +++ b/docker_image_build_files/Dockerfile @@ -44,22 +44,20 @@ ARG FIREBASE_CONFIG ENV FIREBASE_CONFIG=$FIREBASE_CONFIG RUN chmod +x /home/user/projects/baby-equipment-exchange/ + +RUN npm install -g firebase-tools +RUN touch /home/user/projects/baby-equipment-exchange/.env.local + # Accept build-time variables ARG FIREBASE_CONFIG_BASE64 -ARG SERVICE_ACCOUNT_BASE64 # Use a RUN command to create the files from the arguments RUN echo "$FIREBASE_CONFIG_BASE64" | base64 -d > /home/user/projects/baby-equipment-exchange/firebaseConfig.json -RUN echo "$SERVICE_ACCOUNT_BASE64" | base64 -d > /home/user/projects/baby-equipment-exchange/serviceAccount.json - +RUN echo FIREBASE_CONFIG=\"$(jq -c . < firebaseConfig.json)\" >> .env.local -RUN npm install -g firebase-tools -RUN touch /home/user/projects/baby-equipment-exchange/.env.local # the below envinroment variables should be passed through terraform -RUN echo 'GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/serviceAccount.json"' >> /home/user/projects/baby-equipment-exchange/.env.local RUN echo 'FIREBASE_EMULATORS_IMPORT_DIRECTORY="/home/user/projects/baby-equipment-exchange/data_directory/"' >> /home/user/projects/baby-equipment-exchange/.env.local -RUN echo FIREBASE_CONFIG=\"$(jq -c . < firebaseConfig.json)\" >> .env.local ENV FIREBASE_EMULATORS_IMPORT_DIRECTORY="/home/user/projects/baby-equipment-exchange/data_directory/" -ENV GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/serviceAccount.json" + ENV CYPRESS_INSTALL_BINARY=0 # Use a RUN command to export the environment variables From 19f1da55d35dc4acf7dc08380f3d9b744f82f0e0 Mon Sep 17 00:00:00 2001 From: abdullah abbas <46547131+abdullahalhoothy@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:49:24 -0500 Subject: [PATCH 16/18] Update README.md changed namespace --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d407cd7..d768c7b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ docker pull ghcr.io/codeforbtv/baby-equipment-exchange:latest ``` 5. run the docker container ``` -docker run -dit -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 4400:4400 -p 4500:4500 -p 9099:9099 -p 8080:8080 -p 9150:9150 -p 9199:9199 --name baby-equipment-app ghcr.io/abdullahalhoothy/baby-equipment-exchange:latest +docker run -dit -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 4400:4400 -p 4500:4500 -p 9099:9099 -p 8080:8080 -p 9150:9150 -p 9199:9199 --name baby-equipment-app ghcr.io/codeforbtv/baby-equipment-exchange:latest ``` 6. install visual studio code. 7. run visual studio code and install Visual Studio Code Dev Containers extension, for documentation on this extension (https://code.visualstudio.com/docs/devcontainers/containers) From 00f74fe80db39b92827148eb52d3047c3dc49fa3 Mon Sep 17 00:00:00 2001 From: abdulah Date: Thu, 7 Mar 2024 22:08:31 -0500 Subject: [PATCH 17/18] updated the readme with information regarding service account --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d407cd7..f0b1c3f 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,15 @@ docker run -dit -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 4400:4400 -p 4500:4500 10. select the Attach to Container inline action on the container you want to connect to 11. verify your connection by going to the remote tab in VScode 12. open folder and navigate to /home/user/projects/baby-equipment-exchange/ -13. open a new terminal in VScode (verify that it's connected to the container not your host machine) the following command should start the emulators and the app: +13. Create a new file called serviceAccount.json, you need to contact the repo admin to get the content of this file +14. open a new terminal in VScode (verify that it's connected to the container not your host machine) the following command should start the emulators and the app: ``` - +export GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/serviceAccount.json" export FIREBASE_CONFIG="$(cat /home/user/projects/baby-equipment-exchange/firebaseConfig.json)" npm run dev ``` -14. see the output you can run in your host machine browser http://localhost:3000 +15. see the output you can run in your host machine browser http://localhost:3000 From 1ae36364f2c9fd6dc601b91c410dbb6f0f35f9ec Mon Sep 17 00:00:00 2001 From: NathanWEdwards <112483617+NathanWEdwards@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:13:40 -0500 Subject: [PATCH 18/18] Capitalization Fix --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7605709..fad7163 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,19 @@ This project assists the collection and distribution of unused and gently used b 1. install Docker desktop (or equivalent in Mac and Linux) 2. the Docker image is hosted in a the GitHub Packages repository, you'll need to authenticate with GitHub Packages to pull and run the image.you need to authenticate using a GitHub Personal Access Token (PAT) with at least read:packages permission. If you haven't already, generate a PAT by following these steps: -- Go to GitHub and log in. -- Click on your profile picture in the top right corner and go to Settings. -- On the left sidebar, click Developer settings. -- Click on Personal access tokens and then Generate new token. -- Give your token a name, set the expiration, and select at least the read:packages scope under package permissions. - If you also want to push or delete packages, select the appropriate additional scopes. -- Click Generate token at the bottom of the page and make sure to copy your new personal access token; you won't be able to see it again. -3. Log in to GitHub Packages +- go to GitHub and log in. +- click on your profile picture in the top right corner and go to Settings. +- on the left sidebar, click Developer settings. +- click on Personal access tokens and then Generate new token. +- give your token a name, set the expiration, and select at least the read:packages scope under package permissions. - If you also want to push or delete packages, select the appropriate additional scopes. +- click Generate token at the bottom of the page and make sure to copy your new personal access token; you won't be able to see it again. +3. log in to GitHub Packages Use the docker login command to authenticate with GitHub Packages, use the PAT you just created for CR_PAT: ``` export CR_PAT="ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" echo $CR_PAT | docker login ghcr.io -u codeforbtv --password-stdin ``` -4. Now that you're authenticated, you can pull and run the Docker image +4. now that you're authenticated, you can pull and run the Docker image ``` docker pull ghcr.io/codeforbtv/baby-equipment-exchange:latest ``` @@ -31,12 +31,12 @@ docker run -dit -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 4400:4400 -p 4500:4500 ``` 6. install visual studio code. 7. run visual studio code and install Visual Studio Code Dev Containers extension, for documentation on this extension (https://code.visualstudio.com/docs/devcontainers/containers) -8. Download VScode extension called "Remote Development" +8. download VScode extension called "Remote Development" 9. in visual studio code press ctrl+shit+p to open command palette and select Dev Containers: Attach to Running Container (https://code.visualstudio.com/docs/devcontainers/attach-container) 10. select the Attach to Container inline action on the container you want to connect to 11. verify your connection by going to the remote tab in VScode 12. open folder and navigate to /home/user/projects/baby-equipment-exchange/ -13. Create a new file called serviceAccount.json, you need to contact the repo admin to get the content of this file +13. create a new file called serviceAccount.json, you need to contact the repo admin to get the content of this file 14. open a new terminal in VScode (verify that it's connected to the container not your host machine) the following command should start the emulators and the app: ``` export GOOGLE_APPLICATION_CREDENTIALS="/home/user/projects/baby-equipment-exchange/serviceAccount.json"