Code Monkey home page Code Monkey logo

dreitier / mssql-init-db-env-docker Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 11 KB

Sidecar container for creating a new Microsoft SQL Server database and application credentials

Home Page: https://dreitier.com/knowledge-base/devops-in-general/platforms/amazon-web-services/create-rds-sql-server-database-on-ecs-service-startup

Dockerfile 6.32% TSQL 44.82% Shell 48.86%
docker kubernetes ecs rds mssql mssql-database mssql-docker aws-ecs aws

mssql-init-db-env-docker's Introduction

Sidecar container for creating a new Microsoft SQL Server database and application credentials

This Docker image can be used as a sidecard container to ensure that a database, user and login in a Microsoft SQL Server instance is created. This is useful, if you are using Amazon RDS for SQL Server and Amazon Elastic Container Service in a restricted AWS environment. Using this sidecar container is easier than deploying any AWS Lambda/CloudFormation custom resources.

Functionality

  • Database, login and user are only created once. If they are already present, they won't be touched.
  • Roles are only upserted. If the user has already assigned any other, non-specified role that role is kept.

Exit codes

  • The Docker container exits with 0 if everything has been working properly.
  • If any error occurred, the exit codes from sqlcmd will be used. The SQL script itself fails fast. If any error in the SQL statements occurs, it will exit instantly. Transactions are not used.

Environment variables

You can pass the following environment variables with -e VARIABLE=VALUE to the Docker container:

Environment variable Default Description
DATABASE_HOST localhost Host to connect to
DATABASE_PORT 1433 Port to use
DATABASE_PROTOCOL tcp Protocol to use
MASTER_USERNAME sa RDS instance's master username; you'll probably want to inject this with SSM when using AWS
MASTER_PASSWORD Passw0rd! RDS instance's master password; you'll probably want to inject this with SSM when using AWS
DATABASE_NAME app Name of the database
DATABASE_LOGIN app Login
DATABASE_USER app_user User
DATABASE_PASSWORD Passw0rd! Password of the DATABASE_USER; this will not be updated. Rotating is not possible at the moment.
DATABASE_TIMEOUT 5 Timeout in seconds
DATABASE_ROLES db_owner Roles to assign for DATABASE_USER; separated with comma (,), whitespaces are not allowed
TRUST_SERVER_CERTIFICATE 0 If 1, the server certificate is trusted; enable this if you have self-signed certificates
TRUSTED_CONNECTION 0 If 1, the connection is trusted. MASTER_USERNAME and MASTER_PASSWORD can then not be used
AZURE_AD_AUTHENTICATION 0 If 1, Azure AD is used for authentication

Docker

Amazon ECS

Please read this short introduction if you want to use the container with Amazon ECS and CloudFormation.

Create build

docker build -t dreitier/mssql-init-db-env:latest

mssql-init-db-env-docker's People

Contributors

schakko avatar

Watchers

 avatar  avatar  avatar

Forkers

elgohr-update

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.