Skip to content

Commit

Permalink
docker
Browse files Browse the repository at this point in the history
  • Loading branch information
benawad committed Aug 17, 2020
1 parent 2939a82 commit d86acc9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
2 changes: 2 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
22 changes: 22 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:14

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package.json ./
COPY yarn.lock ./

RUN yarn

COPY . .

RUN yarn build

ENV NODE_ENV production

EXPOSE 8080
CMD [ "node", "dist/index.js" ]
USER node
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"dev": "nodemon dist/index.js",
"start": "node dist/index.js",
Expand Down
1 change: 0 additions & 1 deletion server/src/entities/Updoot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ObjectType, Field } from "type-graphql";
import { Entity, BaseEntity, ManyToOne, PrimaryColumn, Column } from "typeorm";
import { User } from "./User";
import { Post } from "./Post";
Expand Down
27 changes: 12 additions & 15 deletions server/src/resolvers/post.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import {
Resolver,
Query,
Arg,
Mutation,
InputType,
Field,
Ctx,
UseMiddleware,
Int,
Field,
FieldResolver,
Root,
InputType,
Int,
Mutation,
ObjectType,
Info,
Query,
Resolver,
Root,
UseMiddleware,
} from "type-graphql";
import { Post } from "../entities/Post";
import { MyContext } from "../types";
import { isAuth } from "../middleware/isAuth";
import { getConnection } from "typeorm";
import { Post } from "../entities/Post";
import { Updoot } from "../entities/Updoot";
import { tmpdir } from "os";
import { User } from "../entities/User";
import { isAuth } from "../middleware/isAuth";
import { MyContext } from "../types";

@InputType()
class PostInput {
Expand Down Expand Up @@ -128,8 +126,7 @@ export class PostResolver {
@Query(() => PaginatedPosts)
async posts(
@Arg("limit", () => Int) limit: number,
@Arg("cursor", () => String, { nullable: true }) cursor: string | null,
@Ctx() { req }: MyContext
@Arg("cursor", () => String, { nullable: true }) cursor: string | null
): Promise<PaginatedPosts> {
// 20 -> 21
const realLimit = Math.min(50, limit);
Expand Down
1 change: 0 additions & 1 deletion server/src/utils/createUpdootLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { User } from "../entities/User";
import { Updoot } from "../entities/Updoot";
import DataLoader from "dataloader";

Expand Down

0 comments on commit d86acc9

Please sign in to comment.