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

Create dev environment #11

Merged
merged 5 commits into from
Dec 25, 2023
Merged
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
build
coverage
.env
22 changes: 22 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run Jest Tests

on: push

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run Jest tests
run: npx jest --verbose ./test/unit/ --coverage
16 changes: 16 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Deploy develop branch to luna-app-backend-dev on fly
on:
push:
branches:
- develop
env:
FLY_API_TOKEN: ${{ secrets.FLY_DEV_TOKEN }}
jobs:
deploy:
name: Deploy Development App
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions@master
with:
args: "deploy -a luna-app-backend-dev --remote-only"
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:20-alpine
WORKDIR /

COPY package*.json ./
RUN npm i -g typescript tsconfig-paths
RUN npm ci
COPY . .

RUN npm run build

EXPOSE 8080
CMD [ "npm", "start" ]
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for luna-app-backend-dev on 2023-12-25T13:10:42-03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

primary_region = "gru"

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 1
processes = ["app"]
restarts = { policy = 'on-fail' }

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 1024
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"dev": "nodemon -r tsconfig-paths/register src/app.ts",
"start": "ts-node -r tsconfig-paths/register src/app.ts",
"start": "node build/src/app.js",
"test": "npm run test:coverage",
"test:unit": "jest --verbose ./test/unit/",
"test:coverage": "jest --verbose ./test/unit/ --coverage",
Expand Down
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { connect } from 'mongoose'
import express, { Request, Response } from 'express'
import Logger from 'src/util/log/Logger'
import Logger from './util/log/Logger'
import HttpStatusCode from './util/enum/HttpStatusCode'
import * as dotenv from 'dotenv'
dotenv.config({ path: __dirname+'/.env' })
dotenv.config({ path: 'src/.env' })

const PORT = process.env.PORT || 3000
const app: express.Application = express()

try {
app.get('/', (req: Request, res: Response) => {
app.get('/', (_req: Request, res: Response) => {
res.status(parseInt(HttpStatusCode.OK)).json({
server: 'Luna App',
status: 'OK'
Expand Down
Loading