diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..47921c0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +/target +tarpaulin-report.html +.env +cobertura.xml +coverage/ +node_modules/ +/static/cache/bundle/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5d9fed7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM node:14.16.0 as frontend +LABEL org.opencontainers.image.source https://github.com/mCaptcha/survey +RUN apt-get update && apt-get install -y make +COPY package.json yarn.lock /src/ +COPY vendor/ /src/vendor +WORKDIR /src +RUN yarn install +COPY . . +RUN make frontend + +FROM rust:1.51.0-slim-buster as rust +WORKDIR /src +RUN apt-get update && apt-get install -y git +COPY . /src +COPY --from=frontend /src/static/cache/bundle /src/static/cache/bundle +ENV RUST_BACKTRACE=1 +RUN cargo build --release + +FROM debian:bullseye-slim +RUN useradd -ms /bin/bash -u 1001 mcaptcha-survey +WORKDIR /home/mcaptcha-survey +COPY --from=rust /src/target/release/survey /usr/local/bin/ +COPY --from=rust /src/config/default.toml /etc/mcaptcha-survey/config.toml +USER mcaptcha-survey +CMD [ "/usr/local/bin/survey" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c4788ee --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3.9' + +services: + mcaptchas-survey: + build: . + ports: + - 7000:7000 + environment: + DATABASE_URL: postgres://postgres:password@postgres:5432/postgres # set password at placeholder + RUST_LOG: debug + + postgres: + image: postgres:13.2 + volumes: + - mcaptcha-survey-data:/var/lib/postgresql/ + environment: + POSTGRES_PASSWORD: password # change password + PGDATA: /var/lib/postgresql/data/mcaptcha/ + +volumes: + mcaptcha-survey-data: