Full Docker Deployment

This commit is contained in:
ortni79929 2020-06-22 14:36:59 +02:00
parent ec7f4c940c
commit f7b58dc850
5 changed files with 38 additions and 10 deletions

25
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,25 @@
image: docker:dind
services:
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
build:
stage: build
script:
- docker build . -t backend:$CI_COMMIT_SHORT_SHA
- docker tag backend:$CI_COMMIT_SHORT_SHA $CI_REGISTRY/taskboard/backend:$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY/taskboard/backend:$CI_COMMIT_SHORT_SHA
- docker tag backend:$CI_COMMIT_SHORT_SHA $CI_REGISTRY/taskboard/backend:latest
- docker push $CI_REGISTRY/taskboard/backend:latest
tags:
- backend

View File

@ -17,5 +17,6 @@ ENV DATABASE_PORT 5432
ENV DATABASE_NAME null
ENV DATABASE_USER null
ENV DATABASE_PASSWORD null
EXPOSE 80
ENTRYPOINT ["dotnet", "ScrumTaskboard.dll"]

View File

@ -4,15 +4,14 @@
> Prerequisite: Docker and Docker Compose have to be installed on your system </br>
> The Docker installation instructions for most operation systems can be found here: [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/) </br>
> The Docker Compose installation instructions for most operation systems can be found here: [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)
> To use the prebuild images log into the private registry: docker login -u testuser -p LpH2v1mShPpC8Xeimkd2AISA03zaC+vq scrumdev.azurecr.io
### Quick Deployment with Docker Compose
1. Clone the git repo
2. Open the cloned repo's folder in a shell of your choice (as long as it supports Docker)
3. Tell Docker Compose to build - if it hasn't already been built - and run the app with `docker-compose up`
3. Tell Docker Compose to run the app alongside a database with `docker-compose up`
Other useful commands:
* Just build: `docker-compose build`
* Build before running: `docker-compose up --build`
* Run attached (in the background): `docker-compose up -d`
* Stop: `docker-compose down`
* Restart: `docker-compose restart`
@ -20,9 +19,9 @@ Other useful commands:
### Build the Container yourself (and run it)
1. Clone the git repo
2. Open the cloned repo's folder in a shell of your choice (as long as it supports Docker)
3. Tell Docker to build the app under the name "taskboard" with `docker build -t taskboard_backend .`
4. Tell Docker to run the app on port 8080 with `docker run -p 8080:80 taskboard_backend`
3. Tell Docker to build the app under the name "taskboard" with `docker build -t taskboard/backend .`
4. Tell Docker to run the app on port 5001 with `docker run -p 5001:80 taskboard/backend`
Other useful commands:
* Run detached: `docker run -d -p 8080:80 taskboard_backend`
* Run under specified name: `docker run -p 8080:80 --name backend taskboard_backend`
* Run detached: `docker run -d -p 5001:80 taskboard/backend`
* Run under specified name: `docker run -p 5001:80 --name backend taskboard/backend`

View File

@ -75,7 +75,11 @@ namespace ScrumTaskboard
{
endpoints.MapControllers();
});
app.UseOpenApi();
app.UseOpenApi(a => {
a.PostProcess = (document, _) => {
document.Schemes = new[] { NSwag.OpenApiSchema.Https, NSwag.OpenApiSchema.Http };
};
});
app.UseSwaggerUi3();
}

View File

@ -13,8 +13,7 @@ services:
networks:
- default
app:
build:
context: .
image: scrumdev.azurecr.io/taskboard/backend:latest
restart: unless-stopped
depends_on:
- db