secret doesn't work yet

This commit is contained in:
hugo gogo
2022-09-07 11:41:23 +02:00
parent 996d408246
commit 035538c95d
4 changed files with 26 additions and 14 deletions

View File

@@ -8,20 +8,16 @@
version: "3.8"
services:
# ---------------------------------
test:
build:
context: ./requirements/test
dockerfile: Dockerfile
image: test
container_name: mytest
# ---------------------------------
nginx:
# restart: on-failure
#restart: on-failure
ports:
- "80:80"
- "443:443"
@@ -29,18 +25,20 @@ services:
context: ./requirements/nginx
dockerfile: Dockerfile
image: nginx
# image: nginx_debian
container_name: mynginx
# container_name: mynginx_debian
# ---------------------------------
mariadb:
# restart: on-failure
#restart: on-failure
build:
context: ./requirements/mariadb
dockerfile: Dockerfile
image: mariadb
container_name: mymariadb
#--secret id=mysecret,src=mysecret.txt
secrets:
- my_secret
# ---------------------------------
secrets:
my_secret:
file: ./secret.txt

View File

@@ -2,14 +2,19 @@ FROM debian:buster
ARG DEBIAN_FRONTEND=noninteractive
# docker build --secret tag : https://docs.docker.com/develop/develop-images/build_enhancements/#new-docker-build-secret-information)
# use secret with docker : https://www.rockyourcode.com/using-docker-secrets-with-docker-compose/)
RUN --mount=type=secret,id=my_secret cat /run/secrets/my_secret.txt
#RUN cat /run/secrets/my_secret.txt
RUN apt update && \
apt install -y mariadb-client mariadb-server && \
rm -rf /var/lib/apt/lists/* && \
\
service mysql start && \
mariadb --execute="create database db_hugo_test;" && \
mariadb --execute="create user 'u_hugo_test'@'localhost' identified by 'hello';" && \
mariadb --execute="grant all privileges on *.* to 'u_hugo_test'@'localhost' with grant option;"
mariadb --execute="CREATE DATABASE db_hugo_test;" && \
mariadb --execute="CREATE USER 'u_hugo_test'@'localhost' IDENTIFIED BY 'hello';" && \
mariadb --execute="GRANT ALL PRIVILEGES ON *.* TO 'u_hugo_test'@'localhost' with grant option;"
CMD [ "mysqld" ]

1
srcs/secret.txt Normal file
View File

@@ -0,0 +1 @@
mon_super_mot_de_passe