-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define base structure of the api folder , and restructure the docker compose , add Makefile
- Loading branch information
Showing
13 changed files
with
1,903 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
APP_NAME="symfony-advanced" | ||
APP_VERSION=dev | ||
APP_ENV=dev | ||
|
||
# Domain | ||
DOMAIN=2aud.io.localhost | ||
API_SUBDOMAIN=api | ||
API_PORT=8000 |
This file contains 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,4 @@ | ||
.idea | ||
.env | ||
/src/api/.pnpm-store/ | ||
/src/api/dist/ |
This file contains 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,9 @@ | ||
.PHONY: start-env | ||
|
||
start-env: | ||
docker compose up | ||
stop-env: | ||
docker compose down | ||
|
||
dive-into-api: | ||
docker-compose exec webapp bash |
This file contains 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 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,52 @@ | ||
|
||
# This Docker Compose file should only be used for your development environment! | ||
version: '3.5' | ||
|
||
services: | ||
|
||
traefik: | ||
image: traefik:2.4 | ||
command: | ||
- --providers.docker | ||
- --providers.docker.exposedByDefault=false | ||
- --api.dashboard=true | ||
- --api.insecure=true | ||
labels: | ||
- traefik.enable=true | ||
- traefik.http.routers.traefik_dashboard_router.rule=Host(`traefik.$DOMAIN`) | ||
- traefik.http.routers.traefik_dashboard_router.service=traefik_dashboard_service | ||
- traefik.http.services.traefik_dashboard_service.loadbalancer.server.port=8080 | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
|
||
api: | ||
build: | ||
context: "./src/api" | ||
labels: | ||
- traefik.enable=true | ||
- traefik.http.routers.api_router.rule=Host(`$API_SUBDOMAIN.$DOMAIN`) | ||
- traefik.http.routers.api_router.service=api_service | ||
- traefik.http.services.api_service.loadbalancer.server.port=$API_PORT | ||
ports: | ||
- "${API_PORT}:${API_PORT}" | ||
command: pnpm dev:api | ||
environment: | ||
# Docker image. | ||
# --------------------- | ||
STARTUP_COMMAND_1: "pnpm install" | ||
STARTUP_COMMAND_2: "pnpm dev:build" | ||
APP_NAME: "$APP_NAME" | ||
APP_VERSION: "$APP_VERSION" | ||
API_PORT: "$API_PORT" | ||
|
||
volumes: | ||
- ./src/api:/usr/src/app | ||
- ~/.ssh:/home/docker/.ssh:ro | ||
|
||
networks: | ||
default: | ||
name: 2aud.io-network | ||
|
||
|
Empty file.
This file contains 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,12 @@ | ||
FROM thecodingmachine/nodejs:v2-18-bullseye | ||
|
||
USER root | ||
|
||
RUN apt-get update -y &&\ | ||
apt-get install openssh-client -y | ||
|
||
RUN npm install -g pnpm | ||
|
||
EXPOSE 8000 | ||
|
||
USER docker |
This file contains 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 @@ | ||
declare namespace NodeJS { | ||
export interface ProcessEnv { | ||
API_PORT: string; | ||
} | ||
} |
This file contains 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,25 @@ | ||
import fastify from 'fastify' | ||
import * as process from "process"; | ||
|
||
const server = fastify({ | ||
logger:true | ||
}) | ||
|
||
server.get('/ping', async (request, reply) => { | ||
return reply.send({ | ||
'ping':'pong' | ||
}) | ||
}) | ||
|
||
const API_PORT = Number(process.env.API_PORT) | ||
|
||
|
||
|
||
server.listen({ port:API_PORT, host:'0.0.0.0'}, (err, address) => { | ||
if (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
console.log(`Server listening at yes ${API_PORT}`) | ||
}) | ||
|
This file contains 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,7 @@ | ||
{ | ||
"verbose": false, | ||
"watch": ["."], | ||
"ext": "ts,js,json", | ||
"ignore": [".git", "node_modules", "/", "/dist"], | ||
"exec": "ts-node index.ts" | ||
} |
This file contains 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,27 @@ | ||
{ | ||
"name": "api", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"dev:build": "tsc", | ||
"dev:api": "tsc-watch --noClear --onSuccess \"nodemon\"", | ||
"preview": "" | ||
}, | ||
"dependencies": { | ||
"fastify": "^4.10.2" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.30.0", | ||
"nodemon": "^2.0.20", | ||
"typescript": "^4.9.4", | ||
"@types/node": "^18.11.16", | ||
"ts-node": "^10.9.1", | ||
"tsc-watch": "^5.0.3", | ||
"@typescript-eslint/eslint-plugin": "^5.46.1", | ||
"@typescript-eslint/parser": "^5.46.1", | ||
"concurrently": "^7.6.0", | ||
"prettier": "^2.8.1", | ||
"dotenv": "^16.0.3" | ||
} | ||
} |
Oops, something went wrong.