diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..cf7e1452 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +node_modules +tests +.git +.github +.next +.swc +.vscode +coverage +certs +.env +.env.test +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..c9800a26 --- /dev/null +++ b/.env.production @@ -0,0 +1,5 @@ +# Only put NEXT_PUBLIC variables here! +# We have to include these at build time, so this file is used to inject them into the build process. +NEXT_PUBLIC_API_URL=/api/ +NEXT_PUBLIC_SLACK_CLIENT_ID=10831824934.7404945710466 +NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-1BFJYBDC76 \ No newline at end of file diff --git a/.env.test b/.env.test index 9268380c..67bb80a9 100644 --- a/.env.test +++ b/.env.test @@ -1,3 +1,7 @@ NEXT_PUBLIC_API_URL=http://localhost:3000/api -DEVELOPER_EMAILS=["test@gmail.com"] \ No newline at end of file +DEVELOPER_EMAILS=["test@gmail.com"] + +TOA_URL=https://example.com +TOA_APP_ID=123 +TOA_KEY=456 \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 7f18da46..60323ed3 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,14 +1,21 @@ name: CD -on: [workflow_call, workflow_dispatch] +on: + workflow_call: + secrets: + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + workflow_dispatch: permissions: packages: write jobs: - build_and_push: + push: runs-on: ubuntu-latest - environment: Test + environment: Production steps: - name: Checkout uses: actions/checkout@v4 @@ -16,15 +23,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and export - uses: docker/build-push-action@v6 - env: - DOCKER_BUILD_SUMMARY: false + - name: Download artifact + uses: actions/download-artifact@v4 with: - tags: ghcr.io/decatur-robotics/gearbox:latest - outputs: type=docker,dest=/tmp/gearbox.tar - context: . # Needed for Docker to find files made during the workflow - + name: gearbox + path: /tmp + - name: Load image run: | docker load --input /tmp/gearbox.tar @@ -34,4 +38,13 @@ jobs: run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin - name: Push to GHCR - run: docker push ghcr.io/decatur-robotics/gearbox:latest \ No newline at end of file + run: docker push ghcr.io/decatur-robotics/gearbox:latest + + - name: Install AWS CLI + uses: unfor19/install-aws-cli-action@v1 + + - name: Configure AWS + run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} && aws configure set region us-east-1 + + - name: Deploy to ECS + run: aws ecs update-service --cluster gearbox --service gearbox --force-new-deployment \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b679f80..90f805e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,12 @@ jobs: with: tags: ghcr.io/decatur-robotics/gearbox:latest outputs: type=docker,dest=/tmp/gearbox.tar + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: gearbox + path: /tmp/gearbox.tar unit_test: runs-on: ubuntu-latest diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index 9ee97423..af6b3f82 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -15,3 +15,6 @@ jobs: needs: - ci uses: ./.github/workflows/cd.yml + secrets: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index e43643f7..00000000 --- a/.gitpod.yml +++ /dev/null @@ -1,11 +0,0 @@ -# This configuration file was automatically generated by Gitpod. -# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) -# and commit this file to your remote git repository to share the goodness with others. - -# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart - -tasks: - - init: npm install && npm run build - command: npm run start - - diff --git a/Dockerfile b/Dockerfile index 2d412f1e..6cbd2ca9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,13 @@ LABEL org.opencontainers.image.licenses=CC-BY-NC-SA-4.0 WORKDIR /app COPY package*.json ./ -RUN npm i +RUN npm ci COPY . . RUN npm run build -EXPOSE 443 +EXPOSE 80 # ENTRYPOINT [ "bash" ] # Uncomment to operate the terminal in the container CMD ["/usr/local/bin/npm", "run", "start"] \ No newline at end of file diff --git a/README.md b/README.md index 0ef6b4a0..e05a572b 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,18 @@ Features full feature parity with SJ2, whilst remaining simpler, faster and cool 1. Run `npm run build` 1. Run `npm run start` +##### Deployment + +See the [Gearbox-Terraform](https://github.com/Decatur-Robotics/Gearbox-Terraform) repo. + #### Tests 1. Run `npm run test` +#### Scripts + +There's a few scripts in the /scripts folder that can be run with `npx tsx scripts/.ts`. + ## Contributing You've made it past set up and are ready to contibure to the future of scouting - here's how. diff --git a/components/Footer.tsx b/components/Footer.tsx index b1569688..d566064b 100644 --- a/components/Footer.tsx +++ b/components/Footer.tsx @@ -151,8 +151,9 @@ export default function Footer() {