From 1883ef1c1cb500fbd70f94400afdf79170838ab0 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Tue, 30 Nov 2021 20:57:32 +0530 Subject: [PATCH] Docker: update image and optimize for layer caching --- Dockerfile | 19 ++++++++++++++++--- README.md | 1 + package.json | 1 + webpack.config.js | 6 +++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32ef93ad..d0e717f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY browser/ /browser WORKDIR /browser RUN wasm-pack build --release -FROM node:14.16.0 as frontend +FROM node:16.0.0 as frontend COPY package.json yarn.lock /src/ COPY --from=wasm /browser /src/browser WORKDIR /src @@ -18,14 +18,27 @@ COPY tsconfig.json webpack.config.js jest.config.ts /src/ COPY templates /src/templates WORKDIR /src RUN yarn build +COPY scripts /src/scripts +RUN /src/scripts/librejs.sh FROM rust:latest as rust WORKDIR /src -COPY . . +RUN mkdir src && echo "fn main() {}" > src/main.rs +COPY Cargo.toml . +RUN sed -i '/.*build.rs.*/d' Cargo.toml +RUN sed -i '/.*browser.*/d' Cargo.toml +COPY Cargo.lock . +COPY migrations /src/migrations +COPY sqlx-data.json /src/ +COPY src/tests-migrate.rs /src/src/tests-migrate.rs +COPY src/settings.rs /src/src/settings.rs +RUN cargo --version +RUN cargo build --release +COPY . /src COPY --from=frontend /src/static/cache/bundle /src/static/cache/bundle RUN cargo build --release -FROM debian:buster +FROM debian:bullseye RUN useradd -ms /bin/bash -u 1001 mcaptcha WORKDIR /home/mcaptcha COPY --from=rust /src/target/release/mcaptcha /usr/local/bin/ diff --git a/README.md b/README.md index 09c50a13..0f31496e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Proof of work based, privacy respecting CAPTCHA system with a kickass UX. [![Documentation](https://img.shields.io/badge/docs-master-blue?style=flat-square)](https://mcaptcha.github.io/mCaptcha/mCaptcha/) [![Build](https://github.com/mCaptcha/mCaptcha/actions/workflows/linux.yml/badge.svg)](https://github.com/mCaptcha/mCaptcha/actions/workflows/linux.yml) +[![Docker](https://img.shields.io/docker/pulls/mcaptcha/mcaptcha)](https://hub.docker.com/r/mcaptcha/mcaptcha) [![dependency status](https://deps.rs/repo/github/mCaptcha/mCaptcha/status.svg?style=flat-square)](https://deps.rs/repo/github/mCaptcha/mCaptcha) [![codecov](https://codecov.io/gh/mCaptcha/mCaptcha/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/mCaptcha/mCaptcha)
diff --git a/package.json b/package.json index ed1148a8..09430f7c 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "vanilla", "main": "index.js", "version": "1.0.0", + "license": "AGPL-3.0", "scripts": { "build": "webpack --mode production", "lint": "yarn run eslint templates", diff --git a/webpack.config.js b/webpack.config.js index 222a7a14..671d8892 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,9 +5,9 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); //const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin'); module.exports = { - devtool: 'inline-source-map', - mode: 'development', - //mode: 'production', + //devtool: 'inline-source-map', + //mode: 'development', + mode: 'production', entry: { bundle: './templates/index.ts', mobile: './templates/mobile.ts',