Skip to content

Commit

Permalink
Merge pull request #133 from LEDBrain/feature/122-api
Browse files Browse the repository at this point in the history
we are merging this because this would stay a WIP branch forever. To not have this issue we will be merging and creating new issues for new Endpoints
  • Loading branch information
kdev authored May 6, 2022
2 parents e791c98 + bb17c9d commit 434fe6f
Show file tree
Hide file tree
Showing 18 changed files with 3,290 additions and 220 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build
on:
push:
workflow_dispatch:

jobs:
build-project:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
env:
PG_USER: postgres
PG_PW: supersecret
PG_DB: community-service-test
DATABASE_URL: postgres://postgres:supersecret@localhost:5432/community-service-test?schema=public

services:
postgres:
image: postgres:14.2
env:
POSTGRES_USER: ${ PG_USER }
POSTGRES_PASSWORD: ${ PG_PW }
POSTGRES_DB: ${ PG_DB }
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Log Database URL
run: echo "Database URL $DATABASE_URL; PG_USER $PG_USER; PG_PW $PG_PW; PG_DB $PG_DB"
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run API tests
run: npm run test:api
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
.env
*.env
db/database.sqlite
dist
.idea
4 changes: 4 additions & 0 deletions .labrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
paths: ['src/api/tests'],
reporter: ['console'],
};
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:16.13.1-alpine as build
WORKDIR /usr/app
COPY . .
RUN npm install
RUN npm run build

FROM node:16.13.1-alpine as cleanup
WORKDIR /usr/app
COPY --from=build /usr/app/package*.json ./
COPY --from=build /usr/app/dist ./dist
COPY --from=build /usr/app/prisma ./prisma
RUN npm install --only=production

FROM node:16.13.1-alpine
WORKDIR /usr/app
COPY --from=cleanup /usr/app ./
USER 1000

EXPOSE 3000

ENV DISCORD_TOKEN $DISCORD_TOKEN
ENV DISCORD_CLIENT_ID $DISCORD_CLIENT_ID
ENV DISCORD_DEV_GUILD_ID $DISCORD_DEV_GUILD_ID
ENV DATABASE_URL $DATABASE_URL
ENV PORT 3000
ENV HOST $HOSTNAME

CMD npm run migrate:prod && npm run start
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.7'

services:
postgres:
image: postgres:14.2
env_file:
- prod.env
volumes:
- ./data:/var/lib/postgresql/data

community-service:
build: .
depends_on:
- postgres
ports:
- '3000:3000'
env_file:
- prod.env
Loading

0 comments on commit 434fe6f

Please sign in to comment.