From d5ec581b36dbe3f77a4c7f95cbf1f1aaa698723c Mon Sep 17 00:00:00 2001 From: Joydip Roy Date: Sat, 14 Oct 2023 12:33:59 +0530 Subject: [PATCH 1/3] chore: localstack added in gitpod --- .gitpod.Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index a7399805..62c09d95 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -10,7 +10,6 @@ RUN mkdir -p $NVM_DIR RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash SHELL ["/bin/bash", "--login", "-c"] -# Install Node.js and PNPM RUN source "$HOME/.nvm/nvm.sh" \ && export NVM_DIR="$HOME/.nvm" \ && [ -s "$NVM_DIR/nvm.sh" ] \ @@ -20,16 +19,18 @@ RUN source "$HOME/.nvm/nvm.sh" \ && nvm use "$VERSION" \ && npm install -g pnpm@latest -# Set up the project +RUN pip install localstack awscli awscli-local + +ENV EXTRA_CORS_ALLOWED_ORIGINS '*' +ENV DISABLE_CORS_CHECKS 1 +ENV DISABLE_CUSTOM_CORS_APIGATEWAY 1 + WORKDIR /workspace -# Copy your project files COPY . . -# Install project dependencies as root user USER root RUN pnpm i --no-frozen-lockfile -# Add a HEALTHCHECK instruction HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD curl -f http://localhost/ || exit 1 From 1c2720fee616190a26e63085b667f35563b04eac Mon Sep 17 00:00:00 2001 From: Joydip Roy Date: Tue, 17 Oct 2023 16:43:49 +0000 Subject: [PATCH 2/3] chore: basic localstack setup for testing --- .github/workflows/ci.yml | 18 ++++++++++++++++++ .gitignore | 1 + cspell.json | 1 + docker/Dockerfile | 32 ++++++++++++++++++++++++++++++++ docker/docker-compose.yml | 15 +++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/docker-compose.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69e86f44..5367855a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,3 +122,21 @@ jobs: with: pass_on_octokit_error: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + localstack: + runs-on: ubuntu-latest + steps: + - name: Start LocalStack + run: | + pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal + docker pull localstack/localstack # Make sure to pull the latest version of the image + localstack start -d # Start LocalStack in the background + + echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container + localstack wait -t 30 # to become ready before timing out + echo "Startup complete" + - name: Run some Tests against LocalStack + run: | + awslocal s3 mb s3://test + awslocal s3 ls + echo "Test Execution complete!" diff --git a/.gitignore b/.gitignore index 92789d41..16d1013a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ dist coverage node_modules temp +volume # Fixtures fixtures/output/* diff --git a/cspell.json b/cspell.json index 33ac5336..0f77e7a0 100644 --- a/cspell.json +++ b/cspell.json @@ -74,6 +74,7 @@ "kohler", "lcov", "linebreak", + "localstack", "lukeed", "markdownlint", "markdownlintignore", diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..a4b229f5 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,32 @@ +FROM alpine:latest + +LABEL rjoydip.image.authors="Joydip Roy (rjoydip)" + +ENV EXTRA_CORS_ALLOWED_ORIGINS '*' +ENV DISABLE_CORS_CHECKS 1 +ENV DISABLE_CUSTOM_CORS_APIGATEWAY 1 +ENV PYTHONUNBUFFERED=1 + +USER root + +RUN addgroup -g 33333 gitpod \ + && mkdir /etc/sudoers.d \ + && echo '%gitpod ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/gitpod \ + && adduser -u 33333 -G gitpod -h /home/gitpod -s /bin/bash -D gitpod \ + && mkdir /workspace && chown -hR gitpod:gitpod /workspace + +WORKDIR /workspace/templ + +RUN apk --no-cache add -U curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ iptables gcompat libstdc++ libgcc libgcc linux-headers grep util-linux binutils findutils nodejs npm python3 py3-pip + +RUN pip3 install --no-cache --upgrade pip setuptools \ + && npm install -g pnpm@latest +# psutil pyproject-toml localstack awscli awscli-local + +COPY . . +RUN pnpm i --no-frozen-lockfile + +HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ + CMD curl -f http://localhost/ || exit 1 + +USER gitpod diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 00000000..b19fcaf4 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3.8" + +services: + localstack: + container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}" + image: localstack/localstack + ports: + - "127.0.0.1:4566:4566" # LocalStack Gateway + - "127.0.0.1:4510-4559:4510-4559" # external services port range + environment: + - DEBUG=${DEBUG-} + - DOCKER_HOST=unix:///var/run/docker.sock + volumes: + - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" + - "/var/run/docker.sock:/var/run/docker.sock" From 1922aa949cf7e5439efa71dfb7f8d5c0d65d6194 Mon Sep 17 00:00:00 2001 From: Joydip Roy Date: Thu, 19 Oct 2023 07:05:38 +0000 Subject: [PATCH 3/3] chore: work in progress --- .gitpod.yml | 8 +--- .nvmrc | 2 +- cspell.json | 2 + docker/Dockerfile | 42 ++++++++++++------- docker/docker-compose.yml | 10 ++++- .../gitpod.Dockerfile | 22 ++++------ 6 files changed, 48 insertions(+), 38 deletions(-) rename .gitpod.Dockerfile => docker/gitpod.Dockerfile (55%) diff --git a/.gitpod.yml b/.gitpod.yml index 07bf47c0..4e44096c 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,20 +1,14 @@ image: - file: .gitpod.Dockerfile - -tasks: - - name: Install Dependencies - init: pnpm i --no-frozen-lockfile + file: docker/gitpod.Dockerfile vscode: extensions: - aaron-bond.better-comments - - codecov.codecov - davidanson.vscode-markdownlint - eamodio.gitlens - editorconfig.editorconfig - esbenp.prettier-vscode - folke.vscode-monorepo-workspace - - google.wireit - foxundermoon.shell-format - mintlify.document - ms-playwright.playwright diff --git a/.nvmrc b/.nvmrc index 08e3ca9b..3e558c9b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18.2.0 +18.12.0 diff --git a/cspell.json b/cspell.json index 0f77e7a0..dfb6d615 100644 --- a/cspell.json +++ b/cspell.json @@ -23,6 +23,8 @@ "autoload", "autodocs", "aquasecurity", + "awscli", + "awslocal", "backreference", "bierner", "brotli", diff --git a/docker/Dockerfile b/docker/Dockerfile index a4b229f5..da743e1a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,26 +7,40 @@ ENV DISABLE_CORS_CHECKS 1 ENV DISABLE_CUSTOM_CORS_APIGATEWAY 1 ENV PYTHONUNBUFFERED=1 -USER root - -RUN addgroup -g 33333 gitpod \ - && mkdir /etc/sudoers.d \ - && echo '%gitpod ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/gitpod \ - && adduser -u 33333 -G gitpod -h /home/gitpod -s /bin/bash -D gitpod \ - && mkdir /workspace && chown -hR gitpod:gitpod /workspace +COPY .nvmrc /tmp/.nvmrc + +RUN apk --no-cache update && \ + apk --no-cache add bash curl && \ + python3.8 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.9/main +# ca-certificates openssl ncurses coreutils make gcc g++ iptables gcompat libstdc++ libgcc libgcc libffi-dev linux-headers grep util-linux binutils findutils + +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash; \ + echo 'source $HOME/.profile;' >> "$HOME"/.zshrc; \ + echo 'export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release;' >>"$HOME"E/.profile; \ + echo 'nvm_get_arch() { nvm_echo "x64-musl"; }' >> "$HOME"/.profile; \ + NVM_DIR="$HOME/.nvm"; source "$HOME"/.nvm/nvm.sh; source "$HOME"/.profile; \ + nvm install "$(cat /tmp/.nvmrc)" && npm install -g pnpm@latest + +RUN apk --no-cache update && \ + apk --no-cache add bash && \ + apk --no-cache add openjdk8-jre && \ + apk --no-cache add python python-dev libstdc++ openssl-dev linux-headers libffi-dev clang make g++ gcc curl groff less && \ + python3 -m ensurepip && \ + rm -r /usr/lib/python*/ensurepip && \ + pip3 --no-cache-dir install --upgrade pip wheel && \ + pip3 --no-cache-dir install -U setuptools && \ + pip3 --no-cache-dir install psutil awscli urllib3 python-coveralls cfn-lint==0.20.0 && \ + rm -rf /var/cache/apk/* + +RUN pip3 --no-cache-dir install localstack awscli awscli-local WORKDIR /workspace/templ -RUN apk --no-cache add -U curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ iptables gcompat libstdc++ libgcc libgcc linux-headers grep util-linux binutils findutils nodejs npm python3 py3-pip - -RUN pip3 install --no-cache --upgrade pip setuptools \ - && npm install -g pnpm@latest -# psutil pyproject-toml localstack awscli awscli-local - COPY . . + RUN pnpm i --no-frozen-lockfile HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD curl -f http://localhost/ || exit 1 -USER gitpod +# USER gitpod diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b19fcaf4..b70436e2 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -4,11 +4,19 @@ services: localstack: container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}" image: localstack/localstack + # build: + # context: . + # dockerfile: Dockerfile ports: - "127.0.0.1:4566:4566" # LocalStack Gateway - - "127.0.0.1:4510-4559:4510-4559" # external services port range + - "127.0.0.1:4510-4559:4510-4559" # External services port range + - "127.0.0.1:53:53" # DNS config + - "127.0.0.1:53:53/udp" # DNS config + - "127.0.0.1:443:443" # LocalStack HTTPS Gateway environment: - DEBUG=${DEBUG-} + - PERSISTENCE=${PERSISTENCE-} + - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-} - DOCKER_HOST=unix:///var/run/docker.sock volumes: - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" diff --git a/.gitpod.Dockerfile b/docker/gitpod.Dockerfile similarity index 55% rename from .gitpod.Dockerfile rename to docker/gitpod.Dockerfile index 62c09d95..37edd4a2 100644 --- a/.gitpod.Dockerfile +++ b/docker/gitpod.Dockerfile @@ -1,12 +1,7 @@ -FROM gitpod/workspace-full:2022-04-11-18-21-27 +FROM gitpod/workspace-full -# Copy .nvmrc files COPY .nvmrc /tmp/.nvmrc -# Set environment variables -ENV NVM_DIR $HOME/nvm -RUN mkdir -p $NVM_DIR - RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash SHELL ["/bin/bash", "--login", "-c"] @@ -14,23 +9,20 @@ RUN source "$HOME/.nvm/nvm.sh" \ && export NVM_DIR="$HOME/.nvm" \ && [ -s "$NVM_DIR/nvm.sh" ] \ && . "$NVM_DIR/nvm.sh" \ - && VERSION="$(cat /tmp/.nvmrc)" \ - && nvm install "$VERSION" \ - && nvm use "$VERSION" \ + && nvm install "$(cat /tmp/.nvmrc)" \ + && nvm use "$(cat /tmp/.nvmrc)" \ && npm install -g pnpm@latest -RUN pip install localstack awscli awscli-local - -ENV EXTRA_CORS_ALLOWED_ORIGINS '*' -ENV DISABLE_CORS_CHECKS 1 -ENV DISABLE_CUSTOM_CORS_APIGATEWAY 1 - +# Set up the project WORKDIR /workspace +# Copy your project files COPY . . +# Install project dependencies as root user USER root RUN pnpm i --no-frozen-lockfile +# Add a HEALTHCHECK instruction HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD curl -f http://localhost/ || exit 1