Skip to content
Open
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
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ dist

# TernJS port file
.tern-port

build/config.gypi
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
48 changes: 21 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ ARG NODE_VERSION=20.18.3

################################################################################
# Use node image for base image for all stages.
FROM node:${NODE_VERSION}-alpine AS base

FROM node:${NODE_VERSION}-alpine as base


# Set working directory for all build stages.
WORKDIR /usr/src/app

USER root


################################################################################
# Create a stage for installing production dependecies.
FROM base AS deps
FROM base as deps



# Install Python and required build tools
RUN apk add --no-cache \
Expand All @@ -33,7 +38,7 @@ RUN apk add --no-cache \

# Download dependencies as a separate step to take advantage of Docker's caching.
COPY package.json package-lock.json install-deps.js ./
COPY tsconfig.json ./

RUN printf '%s\n' '{' \
' "targets": [' \
' {' \
Expand All @@ -46,7 +51,9 @@ RUN npm ci --omit=dev

################################################################################
# Create a stage for building the application.
FROM deps AS build

FROM deps as build


# Download additional development dependencies before building, as some projects require
# "devDependencies" to be installed to build. If you don't need this, remove this step.
Expand All @@ -63,56 +70,43 @@ RUN npm run build
################################################################################
# Create a new stage to run the application with minimal runtime dependencies
# where the necessary files are copied from the build stage.
FROM base AS final

FROM base as final

# Use production node environment by default.
ENV NODE_ENV=production
ENV NODE_PATH=./src:.
ENV NODE_ENV production


# Install runtime shared libraries needed by canvas
RUN apk add --no-cache \
cairo \
jpeg \
pango \
giflib \
pixman
giflib


# Run the application as a non-root user.
USER node

# Copy package.json so that package manager commands can be used.
COPY package.json .
# COPY --from=build /usr/src/app/package.json ./package.json
# COPY --from=build /usr/src/app/package-lock.json ./package-lock.json

COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/package-lock.json ./package-lock.json

COPY --from=build /usr/src/app/tsconfig.json ./tsconfig.json

# Copy the production dependencies from the deps stage and also
# the built application from the build stage into the image.
# COPY --from=deps /usr/src/app/node_modules ./node_modules
# COPY --from=build /usr/src/app/dist ./dist
# COPY package.json package-lock.json ./
# COPY tsconfig.json ./


COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/dist ./dist
COPY --from=build /usr/src/app/assets ./assets
COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/package-lock.json ./package-lock.json
COPY --from=build /usr/src/app/tsconfig.json ./tsconfig.json
COPY . .

# ENV NODE_PATH=./src
# USER root

# RUN npm ci --omit=dev
# RUN npm run build

# Expose the port that the application listens on.
EXPOSE 8080

# Run the application.
CMD ["node", "dist/src/sage.js"]


22 changes: 22 additions & 0 deletions README.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Building and running your application

When you're ready, start your application by running:
`docker compose up --build`.

Your application will be available at http://localhost:8080.

### Deploying your application to the cloud

First, build your image, e.g.: `docker build -t myapp .`.
If your cloud uses a different CPU architecture than your development
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
you'll want to build the image for that platform, e.g.:
`docker build --platform=linux/amd64 -t myapp .`.

Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.

Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
docs for more detail on building and pushing.

### References
* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)
Loading
Loading