-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from UoaWDCC/feat/deployment
Feat/deployment
- Loading branch information
Showing
12 changed files
with
215 additions
and
0 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,29 @@ | ||
name: Fly Deploy Staging | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy-web: | ||
name: Deploy Web | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only --config fly.staging.toml --build-secret VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }} --build-secret VITE_REACT_APP_API_KEY=${{ secrets.VITE_REACT_APP_API_KEY }} --build-secret VITE_REACT_APP_AUTH_DOMAIN=${{ secrets.VITE_REACT_APP_AUTH_DOMAIN }} --build-secret VITE_REACT_APP_STORAGE_BUCKET=${{ secrets.VITE_REACT_APP_STORAGE_BUCKET }} --build-secret VITE_REACT_APP_MESSAGING_SENDER_ID=${{ secrets.VITE_REACT_APP_MESSAGING_SENDER_ID }} --build-secret VITE_REACT_APP_APP_ID=${{ secrets.VITE_REACT_APP_APP_ID }} --build-secret VITE_REACT_APP_MEASUREMENT_ID=${{ secrets.VITE_REACT_APP_MEASUREMENT_ID }} | ||
working-directory: ./frontend | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_STAGING_API_TOKEN }} | ||
|
||
deploy-api: | ||
name: Deploy Api | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only --config fly.staging.toml | ||
working-directory: ./backend | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_STAGING_API_TOKEN }} |
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 @@ | ||
node_modules |
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,41 @@ | ||
# syntax = docker/dockerfile:1 | ||
# Adjust NODE_VERSION as desired | ||
ARG NODE_VERSION=18.19.0 | ||
FROM node:${NODE_VERSION}-slim as base | ||
|
||
LABEL fly_launch_runtime="Node.js" | ||
|
||
# Node.js app lives here | ||
WORKDIR /app | ||
|
||
# Set production environment | ||
ARG YARN_VERSION=1.22.21 | ||
RUN npm install -g yarn@$YARN_VERSION --force | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as install | ||
|
||
# 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 package.json yarn.lock ./ | ||
RUN yarn install --frozen-lockfile | ||
|
||
# Copy application code | ||
COPY --link . . | ||
|
||
FROM base as build | ||
|
||
COPY --from=install /app /app | ||
|
||
# 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 5000 | ||
CMD [ "yarn", "run", "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,18 @@ | ||
app = 'wdcc-vps-api-staging' | ||
primary_region = 'syd' | ||
|
||
[build] | ||
dockerfile = "Dockerfile" | ||
|
||
[http_service] | ||
internal_port = 5000 | ||
force_https = true | ||
auto_stop_machines = true | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
cpu_kind = 'shared' | ||
cpus = 1 | ||
memory_mb = 1024 |
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,3 @@ | ||
dist | ||
node_modules | ||
.env |
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
# production | ||
/build | ||
/dist | ||
|
||
# environment | ||
.env | ||
|
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,65 @@ | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Adjust NODE_VERSION as desired | ||
ARG NODE_VERSION=18.19.0 | ||
FROM node:${NODE_VERSION}-slim as base | ||
|
||
LABEL fly_launch_runtime="Vite" | ||
|
||
# Vite app lives here | ||
WORKDIR /app | ||
|
||
ARG YARN_VERSION=1.22.21 | ||
RUN npm install -g yarn@$YARN_VERSION --force | ||
|
||
# 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 package.json yarn.lock ./ | ||
RUN yarn install --frozen-lockfile --production=false | ||
|
||
# Copy application code | ||
COPY --link . . | ||
|
||
# Set environment variables for Firebase and Clerk | ||
ARG VITE_FIREBASE_PROJECT_ID | ||
ARG VITE_REACT_APP_API_KEY | ||
ARG VITE_REACT_APP_AUTH_DOMAIN | ||
ARG VITE_REACT_APP_STORAGE_BUCKET | ||
ARG VITE_REACT_APP_MESSAGING_SENDER_ID | ||
ARG VITE_REACT_APP_APP_ID | ||
ARG VITE_REACT_APP_MEASUREMENT_ID | ||
|
||
ENV VITE_FIREBASE_PROJECT_ID=${VITE_FIREBASE_PROJECT_ID} | ||
ENV VITE_REACT_APP_API_KEY=${VITE_REACT_APP_API_KEY} | ||
ENV VITE_REACT_APP_AUTH_DOMAIN=${VITE_REACT_APP_AUTH_DOMAIN} | ||
ENV VITE_REACT_APP_STORAGE_BUCKET=${VITE_REACT_APP_STORAGE_BUCKET} | ||
ENV VITE_REACT_APP_MESSAGING_SENDER_ID=${VITE_REACT_APP_MESSAGING_SENDER_ID} | ||
ENV VITE_REACT_APP_APP_ID=${VITE_REACT_APP_APP_ID} | ||
ENV VITE_REACT_APP_MEASUREMENT_ID=${VITE_REACT_APP_MEASUREMENT_ID} | ||
|
||
# Set server URL | ||
ENV VITE_REACT_APP_SERVER_URL="https://wdcc-vps-api-staging.fly.dev" | ||
|
||
# Build the app with environment variables | ||
RUN yarn run build | ||
|
||
# Remove development dependencies | ||
RUN yarn install --production=true | ||
|
||
# Final stage for app image | ||
FROM nginx | ||
|
||
# Copy built application | ||
COPY --from=build /app/dist /usr/share/nginx/html | ||
COPY --link _redirects /usr/share/nginx/html/_redirects | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 80 | ||
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ] |
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 @@ | ||
/* /index.html 200 |
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,19 @@ | ||
app = 'wdcc-vps-staging' | ||
primary_region = 'syd' | ||
|
||
[build] | ||
# dockerfile contains build time non-sensitive env vars | ||
dockerfile = "Dockerfile.staging" | ||
|
||
[http_service] | ||
internal_port = 80 | ||
force_https = true | ||
auto_stop_machines = true | ||
auto_start_machines = true | ||
min_machines_running = 0 | ||
processes = ['app'] | ||
|
||
[[vm]] | ||
cpu_kind = 'shared' | ||
cpus = 1 | ||
memory_mb = 1024 |
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,24 @@ | ||
worker_processes auto; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
server { | ||
listen 80; | ||
|
||
root /usr/share/nginx/html; | ||
index index.html; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} | ||
} |
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