-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pull request preview with graphql (#42)
On this PR; - Create a docker-compose inside `.preview` that builds and runs a environment. - Add `pullpreview` CI action to deploy PR previews to AWS Lightsail. - Add rewrites inside the next configuration to enable the project to contain a single entry point. This is going to be used only on the preview envs. - Add a start action on turbo that runs the start on the `graphql` and `app` packages. ### About PullPreview service The PR preview uses Lightsail from AWS in combination with https://github.com/pullpreview/action does all the work of creating the instance, pulling the code there, and running the `.preview/docker-compose.yaml` They also assign a pretty URL using their domain using [sslip](https://github.com/pullpreview/docker-sslip). This `pullpreview` solution is going to be tested for the next couple of days to evaluate if we are going to keep it or not. Leveraging the 30 days trial, they offer on the license.
- Loading branch information
1 parent
2dd8188
commit 5c9c4b9
Showing
8 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.next | ||
.vercel | ||
.turbo | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Deploy preview | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
types: [labeled, unlabeled, synchronize, closed, reopened] | ||
|
||
jobs: | ||
deploy: | ||
permissions: | ||
contents: read | ||
deployments: write | ||
pull-requests: write | ||
statuses: write | ||
name: deploy | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Add pullpreview label | ||
if: ${{ github.event.action == 'opened' || github.event.action == 'synchronize' }} | ||
uses: KeisukeYamashita/attach-labels@v1 | ||
with: | ||
labels: pullpreview | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: pullpreview/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
compose_files: .preview/docker-compose.yml | ||
env: | ||
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" | ||
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | ||
AWS_REGION: "us-east-1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM node:20-slim AS base | ||
|
||
# Receive envs on build time | ||
ARG IS_PREVIEW | ||
ARG GRAPHQL_API | ||
ARG FUEL_PROVIDER_URL | ||
|
||
# Expose the args to the env of the container | ||
ENV IS_PREVIEW="${IS_PREVIEW}" | ||
ENV GRAPHQL_API="${GRAPHQL_API}" | ||
ENV FUEL_PROVIDER_URL="${FUEL_PROVIDER_URL}" | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
RUN corepack enable | ||
|
||
COPY . /preview | ||
|
||
WORKDIR /preview | ||
|
||
RUN pnpm install --frozen-lockfile | ||
RUN pnpm build:preview | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["pnpm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3.9' | ||
|
||
services: | ||
fuel-explorer: | ||
platform: linux/amd64 | ||
container_name: fuel-explorer | ||
build: | ||
context: ../ | ||
dockerfile: ./.preview/Dockerfile | ||
args: | ||
IS_PREVIEW: true | ||
GRAPHQL_API: http://localhost:4444/graphql | ||
FUEL_PROVIDER_URL: http://beta-4.fuel.network/graphql | ||
ports: | ||
- '80:3000' | ||
- '4000:4444' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters