-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into overview-change-loader
- Loading branch information
Showing
94 changed files
with
1,122 additions
and
1,669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
build | ||
dist | ||
node_modules | ||
server.env | ||
www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
client.env | ||
server.env | ||
|
||
build/* | ||
node_modules/* | ||
dist/* | ||
.DS_Store | ||
.prettierrc | ||
.idea/ | ||
.vscode/ | ||
www/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,60 @@ | ||
FROM --platform=$BUILDPLATFORM node:20-bookworm-slim as nodebuilder | ||
FROM --platform=$BUILDPLATFORM node:20-bookworm-slim AS build | ||
|
||
WORKDIR /node | ||
# Build bento_public with NodeJS + Webpack | ||
# - Use BUILDPLATFORM for running webpack, since it should perform a lot better. | ||
# - Then, the resulting built files will be copied to a TARGETPLATFORM-based final image. | ||
|
||
WORKDIR /bento-public | ||
|
||
# Install using just package-lock.json with npm ci | ||
COPY package.json . | ||
COPY package-lock.json . | ||
|
||
RUN npm ci | ||
|
||
# Build the web application | ||
COPY tsconfig.json . | ||
# Explicitly choose what to copy to speed up builds | ||
# - Copy in build requirements | ||
COPY create_service_info.js . | ||
COPY webpack.config.js . | ||
COPY tsconfig.json . | ||
# - Copy in source code | ||
COPY src src | ||
RUN mkdir -p build/www | ||
RUN npm run build | ||
|
||
|
||
FROM golang:1.21-bookworm as gobuilder | ||
|
||
RUN apt-get update -y && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y git | ||
|
||
WORKDIR /build | ||
|
||
# Only copy the files that are needed! | ||
COPY go.mod . | ||
COPY go.sum . | ||
COPY main.go . | ||
RUN npm run build | ||
|
||
RUN go build -o ./reactapp | ||
FROM nginx:1.26 | ||
|
||
# Install node so that we can run the create_config_prod.js & create_service_info.js scripts | ||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ | ||
apt-get update -y && \ | ||
apt-get install -y ca-certificates curl gnupg && \ | ||
mkdir -p /etc/apt/keyrings && \ | ||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | \ | ||
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ | ||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | \ | ||
tee /etc/apt/sources.list.d/nodesource.list && \ | ||
apt-get install -y nodejs && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
FROM ghcr.io/bento-platform/bento_base_image:node-debian-2024.07.09 | ||
# Serve bento_public with NGINX; copy in configuration | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
ENV BENTO_PUBLIC_PACKAGE_JSON_PATH=/bento-public/package.json | ||
WORKDIR /bento-public | ||
|
||
COPY entrypoint.bash . | ||
COPY package.json . | ||
# In general, we want to copy files in order of least -> most changed for layer caching reasons. | ||
|
||
# - Copy in LICENSE so that people can see it if they explore the image contents | ||
COPY LICENSE . | ||
# - Copy in the production config generation script | ||
COPY create_config_prod.js . | ||
# - Copy in the service info generator | ||
COPY create_service_info.js . | ||
# - Copy in the entrypoint, which writes the config file and starts NGINX | ||
COPY run.bash . | ||
# - Copy in package.json to provide version to scripts | ||
COPY package.json . | ||
# - Copy webpack-built source code from the build stage to the final image | ||
# - copy this last, since it changes more often than everything above it | ||
# - this way we can cache layers | ||
COPY --from=build /bento-public/dist ./dist | ||
|
||
# Copy web app | ||
COPY --from=nodebuilder /node/build/www /bento-public/www | ||
|
||
# Copy server | ||
COPY --from=gobuilder /build/reactapp /bento-public/reactapp | ||
|
||
ENTRYPOINT [ "/bin/bash", "./entrypoint.bash" ] | ||
CMD [ "/bin/bash", "./run.bash" ] | ||
CMD ["bash", "./run.bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const childProcess = require('child_process'); | ||
const packageData = require('./package.json'); | ||
|
||
const nodeEnv = process.env.NODE_ENV || 'production'; | ||
|
||
const serviceType = { | ||
group: 'ca.c3g.bento', | ||
artifact: 'public', | ||
version: packageData.version, | ||
}; | ||
|
||
const serviceID = process.env.SERVICE_ID || `${serviceType.group}:${serviceType.artifact}`; | ||
|
||
const serviceInfo = { | ||
id: serviceID, | ||
name: 'Bento Public', | ||
description: 'Public web interface for the Bento platform.', | ||
type: serviceType, | ||
version: packageData.version, | ||
environment: nodeEnv === 'production' ? 'prod' : 'dev', | ||
organization: { | ||
name: 'C3G', | ||
url: 'https://www.computationalgenomics.ca', | ||
}, | ||
contactUrl: 'mailto:[email protected]', | ||
bento: { | ||
serviceKind: 'public', | ||
}, | ||
}; | ||
|
||
const hasGit = (() => { | ||
try { | ||
return childProcess.execSync('which git').toString().trim() === ''; | ||
} catch (_e) { | ||
// Exit code 1 (git not found) | ||
return false; | ||
} | ||
})(); | ||
const git = (cmd) => childProcess.execSync(`git ${cmd}`).toString().trim(); | ||
if (nodeEnv === 'development' && hasGit) { | ||
try { | ||
serviceInfo.bento.gitTag = git('describe --tags --abbrev=0'); | ||
serviceInfo.bento.gitBranch = git('branch --show-current'); | ||
serviceInfo.bento.gitCommit = git('rev-parse HEAD'); | ||
} catch (e) { | ||
console.warn(`Could not get git information (${e})`); | ||
} | ||
} else if (!hasGit) { | ||
console.warn('Could not get git information (missing git)'); | ||
} | ||
|
||
if (typeof require !== 'undefined' && require.main === module) { | ||
console.log(JSON.stringify(serviceInfo, null, 2)); | ||
} | ||
|
||
module.exports = { | ||
serviceInfo, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
FROM ghcr.io/bento-platform/bento_base_image:node-debian-2024.07.09 | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y ca-certificates | ||
|
||
# Use bookworm-backports to get go 1.21 instead of 1.19 | ||
# Install lsof to help killing the PID binding the port if needed | ||
RUN echo "deb https://deb.debian.org/debian bookworm-backports main contrib non-free" >> /etc/apt/sources.list && \ | ||
echo "deb-src https://deb.debian.org/debian bookworm-backports main contrib non-free" >> /etc/apt/sources.list && \ | ||
apt-get update -y && \ | ||
apt-get upgrade -y && \ | ||
apt-get -t bookworm-backports install -y golang-go lsof && \ | ||
rm -rf /var/lib/apt/lists/* | ||
FROM --platform=$BUILDPLATFORM node:20-bookworm-slim AS install | ||
|
||
WORKDIR /bento-public | ||
|
||
COPY package.json . | ||
COPY package-lock.json . | ||
|
||
# Install NPM dev/prod dependencies to get Nodemon - we will need to fix the permissions of node_modules after | ||
RUN npm ci | ||
|
||
# Don't copy code in, since we expect it to be mounted via volume | ||
FROM ghcr.io/bento-platform/bento_base_image:node-debian-2024.10.01 | ||
|
||
LABEL org.opencontainers.image.description="Local development image for Bento Public." | ||
|
||
WORKDIR /bento-public | ||
|
||
COPY entrypoint.bash . | ||
COPY run.dev.bash . | ||
COPY nodemon.json . | ||
COPY package.json . | ||
COPY package-lock.json . | ||
|
||
COPY --from=install /bento-public/node_modules ./node_modules | ||
|
||
ENTRYPOINT [ "bash", "./entrypoint.bash" ] | ||
CMD [ "bash", "./run.dev.bash" ] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.