Skip to content

Commit

Permalink
Adding new build dockerfile, adding packageManager, basic turbo integ…
Browse files Browse the repository at this point in the history
…ration to get prune

Signed-off-by: Peter Baker <[email protected]>
  • Loading branch information
PeterBaker0 committed Aug 1, 2024
1 parent 186a631 commit 55f4693
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ infrastructure/
docs/
node_modules/
tests/
.env
.env
out
2 changes: 1 addition & 1 deletion .github/workflows/publish-conductor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: ./api/Dockerfile
file: ./api/BuildDockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
keys
build
.turbo
.turbo
out
58 changes: 58 additions & 0 deletions api/BuildDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# syntax=docker/dockerfile:1

# BASED ON https://turbo.build/repo/docs/guides/tools/docker

FROM node:20-alpine as base

FROM base as builder

RUN apk update
RUN apk add --no-cache libc6-compat

# work in /app folder
WORKDIR /app

# install turbo global
RUN npm install turbo@^2.0.11 -g

# copy everything into builder
COPY . .

# prune using turbo for only faims3 and it's dependencies
RUN turbo prune @faims3-project/conductor --docker

# add lockfiles dependencies
FROM base as installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
# COPY --from=builder /app/out/full/library/data-model/tsconfig.json ./library/data-model/tsconfig.json
RUN npm install

# Build the project
COPY --from=builder /app/out/full/ .

# TODO use turbo build here and filter for app
RUN npm run build-api

FROM base AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 faims
USER faims

# Need all of these files from the installer step to run

# The build output
COPY --from=installer --chown=faims:nodejs /app/api/build ./build
# Installed node modules
COPY --from=installer --chown=faims:nodejs /app/node_modules ./node_modules

CMD node ./build/src/index.js
6 changes: 4 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@faims-project/conductor",
"name": "@faims3-project/conductor",
"version": "0.1.0",
"private": true,
"main": "build/src/index.js",
"packageManager": "",
"packageManager": "[email protected]",
"scripts": {
"lint": "gts lint",
"clean": "gts clean",
"compile": "tsc",
"build": "tsc",
"fix": "gts fix",
"prestart": "npm run-script compile",
"start": "node .",
"start:prod": "node build/src/index.js",
"local": "env-cmd nodemon --ignore build --ext ts --exec 'tsc --incremental && node .'",
"watch": "nodemon --ignore build --ext ts --exec 'tsc --incremental && node .'",
"initdb": "env-cmd node scripts/initialise.js",
Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@faims-project/faims3",
"packageManager": "[email protected]",
"version": "0.9.0",
"private": true,
"engines": {
Expand Down
1 change: 1 addition & 0 deletions designer/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "faims3-notebook-designer",
"packageManager": "[email protected]",
"private": true,
"version": "0.0.1",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions infrastructure/aws-cdk/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "aws-cdk-faims-infra",
"packageManager": "[email protected]",
"version": "0.1.0",
"bin": {
"aws-cdk-faims-infra": "bin/aws-cdk-faims-infra.js"
Expand Down
2 changes: 1 addition & 1 deletion library/data-model/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "faims3-datamodel",
"packageManager": "[email protected]",
"version": "1.1.6",
"description": "Database access layer for FAIMS3",
"main": "./build/src/index.js",
Expand All @@ -11,7 +12,6 @@
"build/"
],
"scripts": {
"prepare": "npm run build",
"build": "tsc -p tsconfig.json",
"test": "NODE_ENV=test jest",
"test:watch": "NODE_ENV=test jest --watchAll=true",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
],
"scripts": {
"build-app": "npm run build --workspace=app",
"build-api": "npm run build --workspace=api",
"build-aws": "npm run build --workspace=infrastructure/aws-cdk",
"package-aws": "npm run package --workspace=infrastructure/aws-cdk",
"test-app": "npm test --workspace=app",
Expand All @@ -28,5 +29,6 @@
"description": "",
"devDependencies": {
"turbo": "^2.0.11"
}
},
"packageManager": "[email protected]"
}
1 change: 1 addition & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "FAIMS3-QA",
"packageManager": "[email protected]",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down

0 comments on commit 55f4693

Please sign in to comment.