Skip to content

Commit

Permalink
fix: working docker
Browse files Browse the repository at this point in the history
  • Loading branch information
morgan-cromell committed Nov 15, 2024
1 parent 281da20 commit 48100cb
Show file tree
Hide file tree
Showing 26 changed files with 102 additions and 276 deletions.
18 changes: 5 additions & 13 deletions .docker/dockerfiles/backend
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
FROM diamonds2_base:latest as base
FROM diamonds2_base:latest AS base
WORKDIR /app/packages/backend
RUN apk update && apk add --no-cache openssl libc6-compat
RUN apt-get update -y && apt-get install -y openssl
COPY --chown=1000:1000 packages/backend .

FROM base AS develop
ENV PORT=3000
EXPOSE $PORT
CMD ["yarn", "start:dev"]
CMD ["deno", "run", "start:dev"]

FROM develop AS build
RUN npm run build
RUN SKIP_POSTINSTALL=true yarn workspaces focus --all --production

FROM node:20-alpine AS prod
FROM base AS prod
ENV PORT=3000
WORKDIR /app
COPY --chown=1000:1000 --from=build /app/packages/backend/dist .
COPY --chown=1000:1000 --from=build /app/node_modules ./node_modules
COPY --chown=1000:1000 --from=build /app/packages ./packages
EXPOSE $PORT
CMD ["node", "index.js"]
CMD ["run", "start:prod"]
22 changes: 8 additions & 14 deletions .docker/dockerfiles/base
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
FROM node:20-alpine as base
FROM denoland/deno:2.0.6 AS base
WORKDIR /app
RUN chown 1000:1000 .

# Set yarn version
RUN yarn set version 3.6.3

# Copy root files
COPY --chown=1000:1000 package.json yarn.lock .yarnrc.yml ./

# Copy yarn files
COPY --chown=1000:1000 .yarn/cache .yarn/cache
COPY --chown=1000:1000 .yarn/releases .yarn/releases
COPY --chown=1000:1000 .yarn/plugins .yarn/plugins
COPY --chown=1000:1000 package.json deno.json deno.lock ./

# Copy package.jsons from packages
COPY --chown=1000:1000 packages/backend/package.json packages/backend/package.json
COPY --chown=1000:1000 packages/frontend/package.json packages/frontend/package.json
COPY --chown=1000:1000 packages/types/package.json packages/types/package.json

# Copy deno.jsons from packages
COPY --chown=1000:1000 packages/backend/deno.json packages/backend/deno.json
COPY --chown=1000:1000 packages/frontend/deno.json packages/frontend/deno.json
COPY --chown=1000:1000 packages/types/deno.json packages/types/deno.json

# Install node_modules
RUN yarn install || { cat /tmp/**/build.log; exit 1; }
RUN deno install --allow-scripts

# Copy package sources
COPY --chown=1000:1000 tsconfig.json ./
COPY --chown=1000:1000 packages packages
COPY --chown=1000:1000 scripts scripts

# Build packages
RUN npm run build
6 changes: 3 additions & 3 deletions .docker/dockerfiles/frontend
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM diamonds2_base:latest as base
FROM diamonds2_base:latest AS base
WORKDIR /app/packages/frontend
COPY --chown=1000:1000 packages/frontend .

FROM base AS develop
ENV PORT=8080
EXPOSE $PORT
CMD ["yarn", "dev"]
CMD ["deno", "run", "dev"]

FROM develop AS build
RUN npm run build
RUN deno run build
RUN SKIP_POSTINSTALL=true yarn workspaces focus --all --production

FROM nginx:1.18 AS prod
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,49 @@ If you find a bug or has a suggestion for improvement you are more than welcome
to [submit an issue](https://github.com/Etimo/diamonds2/issues/new) or
[pull request](https://github.com/Etimo/diamonds2/compare)!

## Requirements

Deno

## Development 💻

1. Install dependencies

```sh
yarn
deno install --allow-scripts
```

2. Setup default environment variables

```sh
npm run env
deno run env
```

3. Setup local database

Either

```sh
npm run init-db
deno run init-db
deno run support
```

or

```sh
npm run support
deno run support
# Wait for db to start and navigate to packages/backend
cd packages/backend
# Install prisma
yarn install
# Update db schema
npx prisma db push
deno run db:push
# Seed the database
npx prisma db seed
deno run db:seed
```

4. Start everything

```sh
npm run start
deno run start
```

Frontend: http://localhost:8082
Expand Down
Loading

0 comments on commit 48100cb

Please sign in to comment.