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

feat: Move internals to bunJS #459

Merged
merged 5 commits into from
Jan 2, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
tags:
- v*
pull_request:
branches:
branches:
- master

jobs:
Expand All @@ -16,7 +16,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -31,7 +31,7 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=latest
type=semver,pattern=latest

- name: Login to Docker Hub
uses: docker/login-action@v3
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test the Data
on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3


- name: Setup BunJS
uses: oven-sh/setup-bun@v1

- name: Install deps
run: |
bun install --frozen-lockfile
cd server
bun install --frozen-lockfile

- name: Validate the data
run: bun run validate
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

53 changes: 29 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
FROM node:alpine as BUILD_IMAGE
FROM docker.io/oven/bun:1-alpine as BUILD_IMAGE

WORKDIR /app
# go to work folder
WORKDIR /usr/src/app

ADD package.json package-lock.json ./
ADD server/package.json server/package-lock.json ./server/
ADD --chown=bun:bun package.json bun.lockb ./
ADD --chown=bun:bun server/package.json server/bun.lockb ./server/

# install dependencies
RUN npm ci && \
RUN bun install --frozen-lockfile && \
cd server && \
npm ci
bun install --frozen-lockfile

# Add project files
ADD . .
ADD --chown=bun:bun . .

# build
RUN npm run compile && \
cd server && \
npm run compile && \
npm run build
RUN cd server && \
bun run compile

# remove dev dependencies
RUN npm prune --production && \
cd server && \
npm prune --production
# remove dev dependencies (bun do not yet support "prune")
RUN cd server && \
rm -rf node_modules && \
bun install --frozen-install --production

# go to another VM
FROM node:alpine
FROM docker.io/oven/bun:1-alpine as PROD_IMAGE

# inform software to be in production
ENV NODE_ENV=production

# run as non root user
USER bun

# go to folder
WORKDIR /app
# go to work folder
WORKDIR /usr/src/app

# copy from build image
COPY --from=BUILD_IMAGE /app/server/generated ./generated
COPY --from=BUILD_IMAGE /app/server/node_modules ./node_modules
COPY --from=BUILD_IMAGE /app/server/dist ./dist
COPY --from=BUILD_IMAGE /app/server/public ./public
COPY --from=BUILD_IMAGE /app/server/package.json ./package.json
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/generated ./generated
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/node_modules ./node_modules
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/src ./src
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/public ./public
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/package.json ./package.json

# Expose port
EXPOSE 3000

# run it !
CMD ["npm", "run", "start"]
CMD ["bun", "run", "start"]
Binary file added bun.lockb
Binary file not shown.
Loading