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

Initialize question service #4

Merged
merged 23 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 18 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
10 changes: 10 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is a sample environment configuration file.
# Copy this file to .env and replace the placeholder values with your own.
QUESTION_DB_CLOUD_URI=<FILL-THIS-IN>
QUESTION_DB_LOCAL_URI=mongodb://question-db:27017/question
QUESTION_DB_USERNAME=user
QUESTION_DB_PASSWORD=password
QUESTION_CORS_ORIGIN=*
QUESTION_PORT=8081

NODE_ENV=development
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ env:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-frontend:
build-service:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
service: [frontend, services/question]
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Install Node Modules
run: cd frontend && npm ci
run: cd ${{ matrix.service }} && npm ci
- name: Linting
run: cd frontend && npm run lint
run: cd ${{ matrix.service }} && npm run lint
- name: Build App
run: cd frontend && npm run build
run: cd ${{ matrix.service }} && npm run build
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,45 @@ services:
volumes:
- /app/node_modules
- ./frontend:/app
networks:
- question-network

question:
container_name: question
image: question
build:
context: services/question
dockerfile: Dockerfile
ports:
- 8081:8081
environment:
DB_CLOUD_URI: ${QUESTION_DB_CLOUD_URI}
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
DB_USERNAME: ${QUESTION_DB_USERNAME}
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
volumes:
- /app/node_modules
- ./services/question:/app
networks:
- question-network
- question-db-network

question-db:
container_name: question-db
image: mongo:7.0.14
environment:
MONGO_INITDB_ROOT_USERNAME: ${QUESTION_DB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${QUESTION_DB_PASSWORD}
volumes:
- question-db:/data/db
networks:
- question-db-network

volumes:
question-db:

networks:
question-network:
driver: bridge
question-db-network:
driver: bridge
9 changes: 9 additions & 0 deletions services/question/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is a sample environment configuration file.
# Copy this file to .env and replace the placeholder values with your own.
DB_CLOUD_URI=<FILL-THIS-IN>
DB_LOCAL_URI=mongodb://question-db:27017/question
DB_USERNAME=user
DB_PASSWORD=password
CORS_ORIGIN=*
PORT=8081
NODE_ENV=development
24 changes: 24 additions & 0 deletions services/question/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
39 changes: 39 additions & 0 deletions services/question/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db

package.json
package-lock.json
11 changes: 11 additions & 0 deletions services/question/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"tabWidth": 4,
"useTabs": false,
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"trailingComma": "all",
"bracketSameLine": true,
"printWidth": 120
}
9 changes: 9 additions & 0 deletions services/question/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20-alpine

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
EXPOSE 8081

CMD ["npm", "start"]
24 changes: 24 additions & 0 deletions services/question/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default tseslint.config({
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
eslintPluginPrettierRecommended,
],
rules: {
// https://stackoverflow.com/questions/68816664/get-rid-of-error-delete-eslint-prettier-prettier-and-allow-use-double
'prettier/prettier': [
'error',
{
'endOfLine': 'auto',
}
]
},
});
Loading