Skip to content

Commit

Permalink
Merge pull request #47 from UoaWDCC/deploy
Browse files Browse the repository at this point in the history
setup deployment and actions
  • Loading branch information
alexwillmcleod authored Feb 4, 2024
2 parents d2be6b2 + 0d0f04f commit b6d8728
Show file tree
Hide file tree
Showing 33 changed files with 16,518 additions and 11,974 deletions.
59 changes: 29 additions & 30 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
name: Deploy PROD
name: Deploy to Production

on: [workflow_dispatch]
on:
push:
branches:
- main

jobs:
DeployFrontend:
deploy-strapi:
name: Deploy Strapi Prod
runs-on: ubuntu-latest
environment: PROD
defaults:
run:
working-directory: ./frontend

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.17.0

- name: Create env file
run: echo ${{ secrets.FRONTEND_ENV }} | base64 --decode > .env

- run: npm install

- run: npm run build

- uses: "google-github-actions/auth@v0"
with:
# Credentials stored inside WDCC organisation secrets
credentials_json: "${{ secrets.YOUNITE_GCP_DEPLOYMENT_SA_CREDENTIALS }}"

- id: "app-engine-deploy"
uses: "google-github-actions/deploy-appengine@v0"
with:
flags: --no-cache
project_id: wdcc-younite-prod
working_directory: ./frontend
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config strapi/fly.production.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STRAPI }}
deploy-frontend:
name: Deploy Frontend Prod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config frontend/fly.production.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND }}
deploy-storage:
name: Deploy Storage Prod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config storage/fly.production.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STORAGE }}
35 changes: 35 additions & 0 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy to Staging

on:
push:
branches:
- staging

jobs:
deploy-strapi:
name: Deploy Strapi Staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config strapi/fly.staging.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STRAPI_STAGING }}
deploy-frontend:
name: Deploy Frontend Staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config frontend/fly.staging.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND_STAGING }}
deploy-storage:
name: Deploy Storage Staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config storage/fly.staging.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STORAGE_STAGING }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,5 @@
/strapi/dist
/strapi/build
/strapi/.strapi-updater.json

/strapi/env_vars.*.yaml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Younite's Display Website

Project initiated by WDCC in 2023.

[Guide to getting started](https://drive.google.com/file/d/17aVWCT-alB2iuaeKjuLV3gN6rzv407Ox/view?usp=sharing)
Expand Down
Binary file added README.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
49 changes: 49 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20.0.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Next.js"

# Next.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
ARG PNPM_VERSION=8.3.1
RUN npm install -g pnpm@$PNPM_VERSION


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link .npmrc package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false

# Copy application code
COPY --link . .

# Build application
RUN pnpm run build

# Remove development dependencies
RUN pnpm prune --prod


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "pnpm", "run", "start" ]
1 change: 0 additions & 1 deletion frontend/app.yaml

This file was deleted.

24 changes: 24 additions & 0 deletions frontend/fly.production.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# fly.toml app configuration file generated for younite on 2024-01-23T20:03:27+13:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "younite"
primary_region = "syd"

[env]
STRAPI_URL="https://edit.younite.wdcc.co.nz"

[[vm]]
memory = "1gb"
vm = "performance-1x"



[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
23 changes: 23 additions & 0 deletions frontend/fly.staging.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# fly.toml app configuration file generated for younite on 2024-01-23T20:03:27+13:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "younite-staging"
primary_region = "syd"

[env]
STRAPI_URL="https://staging.edit.younite.wdcc.co.nz"

[[vm]]
memory = "512mb"
vm = "shared-cpu-4x"


[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"zod": "^3.21.4"
},
"devDependencies": {
"@flydotio/dockerfile": "^0.5.0",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2"
Expand Down
Loading

0 comments on commit b6d8728

Please sign in to comment.