Docker: update image and optimize for layer caching

This commit is contained in:
realaravinth 2021-11-30 20:57:32 +05:30
parent eedec7da34
commit 1883ef1c1c
No known key found for this signature in database
GPG Key ID: AD9F0F08E855ED88
4 changed files with 21 additions and 6 deletions

View File

@ -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/

View File

@ -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)
<br />

View File

@ -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",

View File

@ -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',