diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5fe47e2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +**/target/ +**/.vscode/ +**/.env +**/.git/ +**/.dockerignore +**/Dockerfile +**/compose.yaml +**/LICENSE +**/README.md +database/ diff --git a/.gitignore b/.gitignore index 3d2fa55..14dd132 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target/ .env migration/target/ entity/target/ +database/data diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9fd6217 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM docker.io/rust:alpine as builder +WORKDIR /build/pass_manager +RUN apk -U upgrade --no-cache && apk add --no-cache musl-dev +COPY . . +RUN cargo install --path . + +FROM docker.io/alpine +WORKDIR /app/ +RUN apk -U upgrade --no-cache +COPY --from=builder /usr/local/cargo/bin/pass_manager . +CMD ["./pass_manager"] diff --git a/compose.yaml b/compose.yaml new file mode 100755 index 0000000..1bed256 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,30 @@ +version: '3.4' +networks: + password_manager: {} + +services: + passmanager: + build: . + restart: always + environment: + TOKEN: ${TOKEN} + DATABASE_URL: 'mysql://manager:passwd123!@db/passmanager' + depends_on: + - db + networks: + - password_manager + + db: + build: + context: ./database/ + dockerfile: ./Dockerfile + restart: always + environment: + MYSQL_ROOT_PASSWORD: example123! + MYSQL_DATABASE: passmanager + MYSQL_USER: manager + MYSQL_PASSWORD: passwd123! + volumes: + - ./database/data:/var/lib/mysql + networks: + - password_manager diff --git a/database/Dockerfile b/database/Dockerfile new file mode 100755 index 0000000..8d6df06 --- /dev/null +++ b/database/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.io/mariadb + +COPY mariadb.cnf /etc/mysql/mariadb.cnf diff --git a/database/mariadb.cnf b/database/mariadb.cnf new file mode 100755 index 0000000..282855e --- /dev/null +++ b/database/mariadb.cnf @@ -0,0 +1,38 @@ +# The MariaDB configuration file +# +# The MariaDB/MySQL tools read configuration files in the following order: +# 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read. +# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, +# 2. "/etc/mysql/conf.d/*.cnf" to set global options. +# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. +# 4. "~/.my.cnf" to set user-specific options. +# +# If the same option is defined multiple times, the last one will apply. +# +# One can use all long options that the program supports. +# Run program with --help to get a list of available options and with +# --print-defaults to see which it would actually understand and use. +# +# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/ + +# +# This group is read both by the client and the server +# use it for options that affect everything +# +[client-server] +# Port or socket location where to connect +# port = 3306 +socket = /run/mysqld/mysqld.sock + +# Import all .cnf files from configuration directory +[mariadbd] +skip-host-cache +skip-name-resolve + +[mysqld] +skip-innodb +default-storage-engine=Aria +default-tmp-storage-engine=Aria + +!includedir /etc/mysql/mariadb.conf.d/ +!includedir /etc/mysql/conf.d/