Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eidoriantan committed Sep 3, 2023
0 parents commit 699d614
Show file tree
Hide file tree
Showing 98 changed files with 21,376 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
build/
mount/
compilex.db*
npm-debug.log
.*
17 changes: 17 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# Node Runtime variables
DOCKER_CPU_LIMIT=1
DOCKER_MEMORY_LIMIT=256MB
STARTUP_TIMEOUT=5000
EXECUTE_TIMEOUT=30000

DB_KEY=secretkey
JWT_KEY=secretkey
JWT_ISSUER=COMPILEX

# Uncomment if you're using a different port for testing
# CLIENT_PORT=3000
# SERVER_PORT=3001

# Node Build variables
REACT_APP_API=http://localhost:3001
33 changes: 33 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

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

jobs:
build:
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm test
env:
CI: true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
build/
mount/
compilex.db*
npm-debug.log
.env.*
61 changes: 61 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
ARG PORT=3000
ARG MAINTAINER="Adriane Justine Tan <eidoriantan.me>"
ARG DESCRIPTION="COMPILEX Docker image"
ARG VERSION="1.0.0-beta.0"

FROM node:18.17.1-alpine AS builder
LABEL maintainer=${MAINTAINER}
LABEL description=${DESCRIPTION}
LABEL version=${VERSION}

ENV CLIENT_PORT=${PORT}
ENV SERVER_PORT=${PORT}
ENV NODE_ENV=production

RUN apk update
RUN apk add --no-cache python3 gcc g++ make
RUN apk add --no-cache bash curl jq tar

WORKDIR /usr/src/app
COPY package*.json .
RUN npm ci --build-from-source --include=dev

# Copy frontend files for build
COPY public/ public/
COPY src/ src/
COPY tsconfig.json .
COPY webpack.config.js .
RUN npm run build

# Download COMPILEX user program image
WORKDIR /usr/local/bin
RUN wget -q https://raw.githubusercontent.com/moby/moby/master/contrib/download-frozen-image-v2.sh
RUN chmod +x download-frozen-image-v2.sh
RUN download-frozen-image-v2.sh /usr/src/compilex-program eidoriantan/compilex-program:latest

FROM docker:dind
LABEL maintainer=${MAINTAINER}
LABEL description=${DESCRIPTION}
LABEL version=${VERSION}

RUN apk update
RUN apk add --no-cache nodejs=18.17.1-r0 npm

WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/node_modules/ node_modules/
COPY --from=builder /usr/src/app/build/ build/
COPY server/ server/
COPY LICENSE.txt .
COPY package*.json .
RUN npm prune --omit=dev

WORKDIR /usr/src/compilex-program
COPY --from=builder /usr/src/compilex-program .

WORKDIR /usr/local/bin
COPY scripts/start.sh .
RUN chmod +x start.sh

EXPOSE ${PORT}
ENTRYPOINT ["start.sh"]
CMD ["3000"]
10 changes: 10 additions & 0 deletions Dockerfile.program
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:latest
USER root
LABEL maintainer="Adriane Justine Tan <eidoriantan.me>"
LABEL description="COMPILEX Docker image for running user programs."
LABEL version="1.0.0"

# Install supported compilers
RUN apk update
RUN apk --no-cache add g++ gcc
RUN apk --no-cache add openjdk8
Loading

0 comments on commit 699d614

Please sign in to comment.