Skip to content

Commit 5d8ae37

Browse files
icepcpCopilot
andcommitted
finalize v2
Co-authored-by: Copilot <copilot@github.com>
1 parent a8cc4f9 commit 5d8ae37

14 files changed

Lines changed: 936 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,16 @@ jobs:
5555
- name: Set up QEMU
5656
uses: docker/setup-qemu-action@v3
5757

58-
- name: Set up Buildx (docker-container)
58+
- name: Set up buildx
5959
id: buildx
6060
uses: docker/setup-buildx-action@v3
6161
with:
6262
driver: docker-container
6363
use: true
6464

65-
- name: Debug buildx
66-
run: |
67-
docker buildx version
68-
docker buildx ls
69-
7065
- name: Build and push Docker image
7166
uses: docker/build-push-action@v6
67+
id: push
7268
with:
7369
context: ./formsg
7470
file: ./formsg/Dockerfile.production
@@ -86,3 +82,26 @@ jobs:
8682
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
8783
subject-digest: ${{ steps.push.outputs.digest }}
8884
push-to-registry: true
85+
86+
deploy:
87+
needs: build
88+
runs-on: ubuntu-latest
89+
permissions:
90+
id-token: write
91+
contents: read
92+
93+
steps:
94+
- name: Login to azure
95+
uses: azure/login@v2
96+
with:
97+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
98+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
99+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
100+
101+
- name: Deploy new app
102+
uses: azure/cli@v2
103+
with:
104+
inlineScript: |
105+
az extension add --name containerapp --upgrade
106+
az containerapp update -n app -g formsg \
107+
--image ghcr.io/buildingblocs/formbbcs@sha-${GITHUB_SHA::7}

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,21 @@ The backend could run with 1x cpu and 512mb
1010

1111
## v2
1212

13-
v2 has both frontend and backend hosted on Azure, and therefore may require more compute to run. Having frontend on Azure allows for the meta information to work when links are pasted in whatsapp, discord, etc
13+
v2 has both frontend and backend hosted on Azure, and therefore may require more compute to run. Having frontend on Azure allows for the meta information to work when links are pasted in whatsapp, discord, etc. We are using 2C 4G, and have it to scale to 2 instances when needed, but it may be a bit overkill
14+
15+
### How to run
16+
17+
1. Create azure environment
18+
- email, app container
19+
2. create an image by running the action
20+
- make sure you modify some values to your own, like image name and whatnot
21+
3. try to run the app container with the docker image
22+
23+
### Files changed and why
24+
25+
**Backend**
26+
- Removed "attached pdf" text as pdf is no longer generated on server side, and instead on lamda. We dont use aws
27+
28+
**Frontend**
29+
- All mostly just name changes so it is more branded for buildingblocs
30+
- features/admin-form: this is to enable charts feature to try it out

v1/backend/src/app/models/field/imageField.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// myat: v2 azre migration: cant remember why this was added
12
import { Schema } from 'mongoose'
23

34
import { IImageFieldSchema } from '../../../types'

v1/backend/src/app/modules/auth/sso/auth-sso.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// myat v2migration: also cant understand why this was commented out
2+
13
// import { AuthedSessionData } from 'express-session'
24
// import { StatusCodes } from 'http-status-codes'
35
// import { errAsync } from 'neverthrow'

v1/backend/src/app/modules/auth/sso/auth-sso.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// myat v2migration: also cant understand why this was commented out
2+
13
// import { okAsync, ResultAsync } from 'neverthrow'
24
// import { getValidatedIdTokenClaims } from 'oauth4webapi'
35
// import * as oidcClient from 'openid-client'

v1/frontend/frontend/src/features/admin-form/responses/ResponsesPage/storage/StorageResponsesService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const generateDownloadUrl = (
2727

2828
// Stringify all values in params.
2929
const uriEncodedParams = new URLSearchParams(mapValues(params, String))
30-
return `${API_BASE_URL}/${ADMIN_FORM_ENDPOINT}/${formId}/submissions/download?${uriEncodedParams}`
30+
return `${API_BASE_URL}${ADMIN_FORM_ENDPOINT}/${formId}/submissions/download?${uriEncodedParams}`
3131
}
3232

3333
export const getEncryptedResponsesStream = async (
@@ -37,7 +37,6 @@ export const getEncryptedResponsesStream = async (
3737
) => {
3838
// Unable to use axios for streams, and thus using native fetch instead.
3939
return fetch(generateDownloadUrl(formId, params), {
40-
credentials: 'include',
4140
signal: abortController?.signal,
4241
})
4342
.then((res) => res.body)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<style type="text/css">
5+
hr {
6+
margin-top: 20px;
7+
margin-bottom: 20px;
8+
}
9+
</style>
10+
</head>
11+
<body>
12+
Response ID: <%= submissionId %>
13+
<hr />
14+
<% autoReplyBody.forEach(function(line) { %> <%= line %><br />
15+
<% }) %> <% if (locals.refNo) { %>
16+
<br />
17+
<br />
18+
---
19+
<br />
20+
<br />
21+
A summary of your response is shown below. A PDF summary is also attached
22+
for your convenience.
23+
<br />
24+
<br />
25+
<%- include('./submit-form-summary-pdf.server.view.html', { refNo: refNo,
26+
formTitle: formTitle, submissionTime: submissionTime, formData: formData,
27+
formUrl: formUrl, tableOnly: true}) %> <% } %>
28+
</body>
29+
</html>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Meta, StoryFn } from '@storybook/react'
2+
3+
import { viewports } from '~utils/storybook'
4+
5+
import { FooterProps } from './common/types'
6+
import { Footer } from './Footer'
7+
8+
const DEFAULT_ARGS: FooterProps = {
9+
appName: 'Form',
10+
appLink: 'https://form.gov.sg',
11+
footerLinks: [
12+
{
13+
label: 'User guide',
14+
href: '',
15+
},
16+
{
17+
label: 'Privacy',
18+
href: '',
19+
},
20+
{
21+
label: 'Terms of use',
22+
href: '',
23+
},
24+
{
25+
label: 'Report vulnerability',
26+
href: '',
27+
},
28+
],
29+
}
30+
31+
export default {
32+
title: 'Components/Footer',
33+
component: Footer,
34+
decorators: [],
35+
parameters: {
36+
layout: 'fullscreen',
37+
},
38+
args: DEFAULT_ARGS,
39+
} as Meta<FooterProps>
40+
41+
const Template: StoryFn<FooterProps> = (args) => <Footer {...args} />
42+
export const Default = Template.bind({})
43+
44+
export const CompactVariant = Template.bind({})
45+
CompactVariant.args = {
46+
...DEFAULT_ARGS,
47+
variant: 'compact',
48+
}
49+
50+
export const WithTagline = Template.bind({})
51+
WithTagline.args = {
52+
...DEFAULT_ARGS,
53+
tagline: 'Build secure BuildingBloCS forms in minutes',
54+
}
55+
56+
export const Mobile = Template.bind({})
57+
Mobile.parameters = {
58+
viewport: {
59+
defaultViewport: 'mobile1',
60+
},
61+
chromatic: { viewports: [viewports.xs] },
62+
}
63+
64+
export const Tablet = Template.bind({})
65+
Tablet.parameters = {
66+
viewport: {
67+
defaultViewport: 'tablet',
68+
},
69+
chromatic: { viewports: [viewports.md] },
70+
}

0 commit comments

Comments
 (0)