Skip to content
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

Enable initial dockerized deployment #7

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
#currently we build manually...
!src
!scripts
!package.json
!package-lock.json
6 changes: 6 additions & 0 deletions .env-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TCQ_GH_SECRET:
TCQ_LOCAL_GH_SECRET:
TCQ_GH_ID:
TCQ_LOCAL_GH_ID:
TCQ_SESSION_SECRET:
TCQ_GH_CALLBACK_URL:
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
set-secrets.ps1
node_modules
dist
dist

#ide
.idea

#envs
.env-development
.env-production

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.19.0
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Building

`docker compose run --rm -i builder /bin/bash` and then run `npm i && npm run postinstall && npm run build-frontend && npm run build-backend`

# Local Development
* You need a GitHub OAuth app with `clientId` and `clientSecret`, these need to be set in `.env-development` that you can copy over from `.env-template` and set `TCQ_LOCAL_GH_SECRET`, `TCQ_LOCAL_GH_ID` and `TCQ_SESSION_SECRET`. Its `callbackUrl` _should_ be set to `http://localhost:3000/auth/github/callback`.

If you have a proper build, you can then run a dev container with `docker compose up dev`.
5 changes: 5 additions & 0 deletions builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:20.04 AS builder

RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install nodejs npm

WORKDIR /opt/build
1 change: 1 addition & 0 deletions copilot/.workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application: tcq-reloaded
21 changes: 21 additions & 0 deletions copilot/environments/staging/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The manifest for the "staging" environment.
# Read the full specification for the "Environment" type at:
# https://aws.github.io/copilot-cli/docs/manifest/environment/

# Your environment name will be used in naming your resources like VPC, cluster, etc.
name: staging
type: Environment

# Import your own VPC and subnets or configure how they should be created.
# network:
# vpc:
# id:

# Configure the load balancers in your environment, once created.
# http:
# public:
# private:

# Configure observability for your environment resources.
observability:
container_insights: false
57 changes: 57 additions & 0 deletions copilot/tcq/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# The manifest for the "tcq" service.
# Read the full specification for the "Load Balanced Web Service" type at:
# https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/

# Your service name will be used in naming your resources like log groups, ECS services, etc.
name: tcq
type: Load Balanced Web Service

# Distribute traffic to your service.
http:
# Requests to this path will be forwarded to your service.
# To match all requests you can use the "/" path.
path: '/'
# You can specify a custom health check path. The default is "/".
# healthcheck: '/'

# Configuration for your containers and service.
image:
# Docker build arguments. For additional overrides: https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/#image-build
build: service.Dockerfile
# Port exposed through your container to route traffic to it.
port: 3000

cpu: 256 # Number of CPU units for the task.
memory: 512 # Amount of memory in MiB used by the task.
platform: linux/arm64 # See https://aws.github.io/copilot-cli/docs/manifest/lb-web-service/#platform
count: 1 # Number of tasks that should be running in your service.
exec: true # Enable running commands in your container.
network:
connect: true # Enable Service Connect for intra-environment traffic between services.

# storage:
# readonly_fs: true # Limit to read-only access to mounted root filesystems.

# Optional fields for more advanced use-cases.
#
#variables: # Pass environment variables as key value pairs.
# LOG_LEVEL: info
variables: # Pass environment variables as key value pairs.
TCQ_GH_CALLBACK_URL: https://tcq.${COPILOT_ENVIRONMENT_NAME}.tcq-reloaded.tcq.ninja/auth/github/callback
TCQ_DB_ADAPTER: mongodb
TCQ_SESSION_STORE_ADAPTER: mongodb

secrets: # Pass secrets from AWS Systems Manager (SSM) Parameter Store.
# GITHUB_TOKEN: GITHUB_TOKEN # The key is the name of the environment variable, the value is the name of the SSM parameter.
TCQ_GH_SECRET: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TCQ_GH_SECRET
TCQ_SESSION_SECRET: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TCQ_SESSION_SECRET
TCQ_GH_ID: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TCQ_GH_ID
TCQ_DB_MONGODB_URI: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TCQ_DB_MONGODB_URI
TCQ_SESSION_STORE_MONGODB_URI: /copilot/${COPILOT_APPLICATION_NAME}/${COPILOT_ENVIRONMENT_NAME}/secrets/TCQ_DB_MONGODB_URI

# You can override any of the values defined above by environment.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
builder:
image: tc39/tcq-builder
build:
dockerfile: builder.Dockerfile
volumes:
- ./:/opt/build
dev:
image: node:10.19-slim
volumes:
- ./dist:/dist
- ./node_modules:/node_modules
env_file:
- .env-development
command: node dist/server/server.js
ports:
- 3000:3000

prod:
image: tc39/tcq-reloaded
build:
dockerfile: service.Dockerfile
env_file:
- .env-production
ports:
- 3000:3000
Loading