Skip to content

Commit

Permalink
feat(development-environment): add development environment with yarn
Browse files Browse the repository at this point in the history
Add development environment with yarn to abstract nodemon restarts and husky to format code
  • Loading branch information
FelipeBarrosCruz committed May 24, 2020
1 parent b135736 commit 1e341b6
Show file tree
Hide file tree
Showing 9 changed files with 1,112 additions and 10 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
21 changes: 18 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
FROM hayd/alpine-deno:1.0.1
FROM hayd/alpine-deno:1.0.1 AS base

USER deno

WORKDIR /app
WORKDIR /usr/app

ADD . .
COPY . .

# development
FROM hayd/alpine-deno:1.0.1 AS development

RUN apk add --update yarn

WORKDIR /usr/app

COPY --from=base /usr/app .

RUN yarn install

ENTRYPOINT [ "yarn" ]

CMD ["dev"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ kill:

up:
@docker-compose up

deno:
@yarn deno
11 changes: 6 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
version: '3'
version: '3.4'
services:
app:
build: .
build:
context: .
target: development
container_name: app
command: run --allow-env --allow-read --allow-net -q src/index.ts
networks:
- deno-app-network
volumes:
- .:/app
volumes:
- .:/usr/app
ports:
- 3000:3000
expose:
Expand Down
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "deno-playground",
"version": "1.0.0",
"description": "Deno playground",
"main": "index.js",
"scripts": {
"start": "yarn deno",
"deno": "deno run --allow-env --allow-read --allow-net -q src/index.ts",
"dev": "nodemon -e ts --watch src --exec yarn start"
},
"husky": {
"hooks": {
"pre-commit": "deno fmt src"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/FelipeBarrosCruz/deno-playground.git"
},
"keywords": [
"deno",
"playground"
],
"author": "FelipeBarrosCruz <felipe.barros.pt@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/FelipeBarrosCruz/deno-playground/issues"
},
"homepage": "https://github.com/FelipeBarrosCruz/deno-playground#readme",
"devDependencies": {
"husky": "^4.2.5",
"nodemon": "^2.0.4"
}
}
2 changes: 1 addition & 1 deletion src/http/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import logger from "../logger/index.ts";

const { APP_PORT } = config;

logger.info(`Deno HTTP Server Running on port ${APP_PORT}`)
logger.info(`Deno HTTP Server Running on port ${APP_PORT}`);

export default serve({
port: Number(APP_PORT),
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ for await (const request of server) {
logger.info("Request received");
request.respond({ body: "Hello World" });
}

Loading

0 comments on commit 1e341b6

Please sign in to comment.