docker: wasm build step

This commit is contained in:
realaravinth 2021-07-15 15:27:01 +05:30
parent 883aa122b2
commit 97db774e70
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
3 changed files with 29 additions and 12 deletions

View file

@ -8,3 +8,7 @@ node_modules/
./templates/**/*.js
/static/cache/bundle/*
src/cache_buster_data.json
browser/target
browser/cobertura.xml
browser/docs

View file

@ -1,16 +1,28 @@
FROM node:14.16.0 as frontend
FROM rust:latest as wasm
LABEL org.opencontainers.image.source https://github.com/mCaptcha/mCaptcha
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
COPY browser/ /browser
WORKDIR /browser
RUN wasm-pack build --release
FROM node:14.16.0 as frontend
COPY package.json yarn.lock /src/
COPY --from=wasm /browser /src/browser
WORKDIR /src
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
WORKDIR /
RUN mkdir -p /src/static/cache/bundle
COPY tsconfig.json webpack.config.js jest.config.ts /src/
COPY templates /src/templates
WORKDIR /src
RUN yarn build
FROM rust:latest as rust
COPY --from=frontend /src /src
WORKDIR /src
COPY . .
COPY --from=frontend /src/static/cache/bundle /src/static/cache/bundle
RUN cargo build --release
FROM debian:buster

View file

@ -2,11 +2,12 @@ default: frontend
cargo build
clean:
cargo clean
rm -rf browser/pkg || true
rm ./src/cache_buster_data.json || true
rm -rf ./static/cache/bundle || true
rm -rf ./assets || true
@cargo clean
@yarn cache clean
@-rm -rf browser/pkg
@-rm ./src/cache_buster_data.json
@-rm -rf ./static/cache/bundle
@-rm -rf ./assets
coverage: migrate
cd browser && cargo tarpaulin -t 1200 --out Html
@ -21,10 +22,10 @@ doc:
cargo doc --no-deps --workspace --all-features
cd browser && cargo doc --no-deps --workspace --all-features
docker-build:
docker:
docker build -t mcaptcha/mcaptcha:master -t mcaptcha/mcaptcha:latest .
docker-publish: docker-build
docker-publish:
docker push mcaptcha/mcaptcha:master
docker push mcaptcha/mcaptcha:latest
@ -61,7 +62,7 @@ help:
@echo ' clean - drop builds and environments'
@echo ' coverage - build test coverage in HTML format'
@echo ' dev-env - download dependencies'
@echo ' docker-build - build docker image'
@echo ' docker - build docker image'
@echo ' docker-publish - build and publish docker image'
@echo ' doc - build documentation'
@echo ' frontend - build static assets in prod mode'