-
Notifications
You must be signed in to change notification settings - Fork 0
Make mstacm api production ready #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3531316
Fix the ability to generate migrations
kevinschoonover ae50774
Fix entity detection in production
kevinschoonover 51b4019
Add auto seeding of schema + initial data via migrations
kevinschoonover 12d1c8c
Add auth0 sub for default user in migration
kevinschoonover 0c7b176
Add initial .circleci config + fix 'start:prod' failing
kevinschoonover 1e9eebc
Add basic App.tsx render test
kevinschoonover 542631c
Add docker-compose production configuration w/ deploy script
kevinschoonover File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,61 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
# specify the version you desire here | ||
- image: circleci/node:lts | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
# documented at https://circleci.com/docs/2.0/circleci-images/ | ||
# - image: circleci/mongo:3.4.4 | ||
|
||
working_directory: ~/mstacm.org/apps/web | ||
|
||
steps: | ||
- checkout: | ||
path: ~/mstacm.org | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "yarn.lock" }} | ||
|
||
# run tests! | ||
- run: yarn test | ||
|
||
# TODO: when we have access to a production machine with SSH access | ||
# deploy: | ||
# machine: | ||
# enabled: true | ||
# working_directory: ~/mstacm.org/apps/web | ||
# steps: | ||
# - run: | ||
# name: Deploy Over SSH | ||
# command: | | ||
# ssh $SSH_USER@$SSH_HOST "cd /opt/mstacm.org/api && git pull && bash deploy.sh" | ||
# workflows: | ||
#workflows: | ||
# version: 2 | ||
# build-and-deploy: | ||
# jobs: | ||
# - build | ||
# - deploy: | ||
# requires: | ||
# - build | ||
# filters: | ||
# branches: | ||
# only: master |
This file contains hidden or 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 |
---|---|---|
|
@@ -14,3 +14,40 @@ docker-compose up | |
|
||
## Developing | ||
I recommend installing [altair](https://altair.sirmuel.design/). | ||
|
||
## Deployment | ||
The deployment of the website is targeted to be as automated as possible, but | ||
these steps serve as a safe guard in case something breaks or to bolster | ||
understanding of the underlying system. | ||
|
||
To setup automatic deployment, perform the following steps: | ||
1. ssh into the production server: | ||
```bash | ||
ssh changeme-user@changeme-host | ||
``` | ||
2. If this is a fresh new server, perform some kind of ssh hardening | ||
as automatic deployment currently occurs over ssh: | ||
+ https://linux-audit.com/audit-and-harden-your-ssh-configuration/ | ||
+ https://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html | ||
+ https://medium.com/@jasonrigden/hardening-ssh-1bcb99cd4cef | ||
3. Install [Docker Compose](https://docs.docker.com/compose/install/) | ||
4. Clone the `mstacm.org` repo in `/opt/`: | ||
```bash | ||
cd /opt/ | ||
sudo git clone [email protected]:sigdotcom/mstacm.org.git | ||
sudo chown -R <YOUR_USERNAME>:<YOUR_USERNAME> mstacm.org/ | ||
``` | ||
5. Setup the necessary secrets: | ||
```bash | ||
# Enter the directory | ||
cd mstacm.org/api | ||
# Create docker environment variable file | ||
cp .docker/web.env.default .docker/web.env | ||
vim .docker/web.env | ||
# Return to root repository directory | ||
cd .. | ||
``` | ||
5. Run `deploy.sh` in the root repository: | ||
```bash | ||
bash deploy.sh | ||
``` |
This file contains hidden or 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 hidden or 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,8 @@ | ||
version: '3' | ||
|
||
services: | ||
phoenix_web: | ||
command: yarn start:dev | ||
build: . | ||
volumes: | ||
- .:/server |
This file contains hidden or 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,5 @@ | ||
version: '3' | ||
|
||
services: | ||
phoenix_web: | ||
image: "acmweb/api" |
This file contains hidden or 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 hidden or 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,6 @@ | ||
{ | ||
"watch": ["src"], | ||
"ext": "ts", | ||
"ignore": ["src/**/*.spec.ts"], | ||
"exec": "ts-node -r tsconfig-paths/register src/main.ts" | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -10,23 +10,25 @@ export async function seedDatabase() { | |
const defaultUser = userRepository.create({ | ||
email: "[email protected]", | ||
firstName: "Kevin", | ||
googleSub: "123421", | ||
sub: "123421", | ||
lastName: "Schoonover" | ||
}); | ||
await userRepository.save(defaultUser); | ||
|
||
await productRepository | ||
.create({ | ||
description: "Payment for ACM Yearly Membership", | ||
name: "ACM Yearly Membership", | ||
displayName: "ACM Yearly Membership", | ||
tag: "yearly-membership", | ||
price: 20 | ||
}) | ||
.save(); | ||
|
||
await productRepository | ||
.create({ | ||
description: "Payment for ACM Semesterly Membership", | ||
name: "ACM Semesterly Membership", | ||
displayName: "ACM Semesterly Membership", | ||
tag: "semesterly-membership", | ||
price: 11 | ||
}) | ||
.save(); | ||
|
This file contains hidden or 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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
import { ParameterizedContext } from "koa"; | ||
import { User } from "../User"; | ||
|
||
export interface IContext extends ParameterizedContext {} | ||
|
||
interface IOwnership { | ||
isOwner(user: User): boolean; | ||
} |
This file contains hidden or 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,11 @@ | ||
// WARNING: be very careful about editting this file | ||
// as it is tied directly to the initial_values migration. | ||
// DO NOT edit this file unless you know what you're doing. | ||
|
||
export const YEARLY_MEMBERSHIP = { | ||
tag: "yearly-membership" | ||
}; | ||
|
||
export const SEMESTERLY_MEMBERSHIP = { | ||
tag: "semesterly-membership" | ||
}; |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.