Skip to content

Commit

Permalink
Merge pull request #109 from DSC-McMaster-U/dockfile_frontend
Browse files Browse the repository at this point in the history
Dockerfile running for frontend and Secrets for Terraform
  • Loading branch information
ausbennett authored Nov 8, 2023
2 parents 8c5da5b + fac66cc commit d386435
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 142 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/manual_terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Manual Terraform Deployment'

on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
default: 'dev'

jobs:
terraform:
name: 'Deploy to Environment'
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.environment }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Google Cloud SDK
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.DEFAULT_SA_KEY }}
project_id: ${{ secrets.PROJECT_ID }}

- name: Install Terraform
uses: hashicorp/setup-terraform@v1

- name: Set up Terraform credentials
run: |
echo "GOOGLE_CREDENTIALS=${{ secrets.DEFAULT_SA_KEY }}" >> $GITHUB_ENV
- name: Terraform Init
run: terraform init

- name: Terraform Plan
run: terraform plan -out=tfplan

- name: Hold for approval
if: github.event_name == 'workflow_dispatch'
uses: softprops/turnstyle@v1
with:
continue-after-seconds: 0 # This will make it wait indefinitely until manually approved
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Terraform Apply
if: github.event_name == 'workflow_dispatch'
run: terraform apply tfplan
2 changes: 1 addition & 1 deletion cloud-infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variable "zone" {
provider "google" {
project = var.project
region = var.region
credentials = file("credentials.json")
credentials = jsondecode("${var.GOOGLE_CREDENTIALS}")
zone = var.zone
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": ["next/babel", "next/core-web-vitals"]
"extends": ["next", "next/core-web-vitals"]
}
35 changes: 35 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Stage 1: Building the code
FROM node:16-alpine AS builder

WORKDIR /app

# Copy the package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy the app source code
COPY . .

# Build the app
RUN npm run build

# Stage 2: Run the app
FROM node:16-alpine AS runner
WORKDIR /app

# Copy built assets from the builder stage
COPY --from=builder /app/.next/ .next/
COPY --from=builder /app/node_modules/ node_modules/
COPY --from=builder /app/public/ public/
COPY --from=builder /app/package.json package.json

# Expose the port Next.js runs on
EXPOSE 3000

# Set environment to production to avoid including unnecessary files
ENV NODE_ENV production

# Start the app
CMD ["npm", "start"]
134 changes: 1 addition & 133 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions frontend/src/components/NavigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import MenuIcon from "@mui/icons-material/Menu";
import Container from "@mui/material/Container";
import Button from "@mui/material/Button";
import MenuItem from "@mui/material/MenuItem";
import AutoMateLogo from "../../public/Automate_logo.png";
import Image from "next/image";
import Link from "next/link";

Expand All @@ -31,7 +30,12 @@ function NavigationBar() {
<Container maxWidth="xl">
<Toolbar disableGutters>
<Box sx={{ display: { xs: "none", md: "flex" }, mr: 1 }}>
<Image width={50} alt="AutoMate Logo" src={AutoMateLogo} />
<Image
width={50}
height={50}
alt="AutoMate Logo"
src="/AutoMate_logo.png"
/>
</Box>
<Typography
variant="h6"
Expand Down Expand Up @@ -94,8 +98,13 @@ function NavigationBar() {
</Menu>
</Box>

<Box sx={{ display: { xs: "flex", md: "none" }, mr: 1 }}>
<Image width={50} alt="AutoMate Logo" src={AutoMateLogo} />
<Box sx={{ display: { xs: "none", md: "flex" }, mr: 1 }}>
<Image
width={50}
height={50}
alt="AutoMate Logo"
src="/AutoMate_logo.png"
/>
</Box>
<Typography
variant="h5"
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from "react";
import Typography from "@mui/material/Typography";
import "@fontsource/public-sans";
import AutoMateLogo from "../../public/Automate_logo.png";
import Image from "next/image";
import Button from "@mui/material/Button";
import styled from "@emotion/styled";
Expand Down Expand Up @@ -120,8 +119,13 @@ export default function Home() {
</Button>
</Element>
</Element>
<Picture style={{ left: "10" }}>
<Image width={500} alt="AutoMate Logo" src={AutoMateLogo} />
<Picture>
<Image
width={500}
height={500}
alt="AutoMate Logo"
src="/AutoMate_logo.png"
/>
</Picture>
</BoxContainer>
</Container>
Expand Down

0 comments on commit d386435

Please sign in to comment.