Coder Social home page Coder Social logo

Support for ACR about farmer HOT 38 CLOSED

compositionalit avatar compositionalit commented on August 15, 2024
Support for ACR

from farmer.

Comments (38)

isaacabraham avatar isaacabraham commented on August 15, 2024 1

Also this link provides the details on the ARM spec for ACR: https://docs.microsoft.com/en-us/azure/templates/microsoft.containerregistry/2017-10-01/registries

from farmer.

dburriss avatar dburriss commented on August 15, 2024 1

@JordanMarr I have the following working. What features are you using?
I am guessing linking Identity is a must. Tasks? Encryption? Geo-replication?

open Farmer
open Farmer.Resources.ContainerRegistry

let myRegistry = containerRegistry {
    name "devonRegistry"
    sku Basic
    enable_admin_user
}

let deployment = arm {
    location WestEurope
    add_resource myRegistry
    output "registry" myRegistry.Name
}

deployment
|> Deploy.execute "FarmerTest" Deploy.NoParameters

@isaacabraham How do you usually handle a feature? Should I prefer to releasing a minimal set of features and increment, or aim for feature-complete?

from farmer.

dburriss avatar dburriss commented on August 15, 2024 1

Opened a PR for review and comments #129

from farmer.

dburriss avatar dburriss commented on August 15, 2024 1

@isaacabraham I changed my tests over to Expecto. Hopefully, IntelliJ pulls through and delivers support for Expecto tests in the 2020.2 Rider release.

Please let me know if anything else. I will take a quick look at how updating the docs is done.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

Not as far as I know - @ninjarobot do you have any plans for this?

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@dburriss I think @forki also has some interest in this and we might be adding it to web apps shortly.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

Here's how it's looking at the moment...

let myDockerApp = webApp {
    name "isaacssuperapp"
    app_insights_off
    docker_image "myImage" "startup.dll"
    docker_ci
    docker_registry_credentials "www.myuri.com" "userisaac"
}

Generates the following ARM template:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "outputs": {},
  "parameters": {
    "docker-password-for-isaacssuperapp": {
      "type": "securestring"
    }
  },
  "resources": [
    {
      "apiVersion": "2016-08-01",
      "dependsOn": [
        "isaacssuperapp-plan"
      ],
      "kind": "app,linux,container",
      "location": "northeurope",
      "name": "isaacssuperapp",
      "properties": {
        "httpsOnly": false,
        "serverFarmId": "isaacssuperapp-plan",
        "siteConfig": {
          "alwaysOn": false,
          "appCommandLine": "startup.dll",
          "appSettings": [
            {
              "name": "DOCKER_ENABLE_CI",
              "value": "true"
            },
            {
              "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
              "value": "[parameters('docker-password-for-isaacssuperapp')]"
            },
            {
              "name": "DOCKER_REGISTRY_SERVER_URL",
              "value": "www.myuri.com"
            },
            {
              "name": "DOCKER_REGISTRY_SERVER_USERNAME",
              "value": "userisaac"
            }
          ],
          "linuxFxVersion": "DOCKER|myImage",
          "metadata": []
        }
      },
      "type": "Microsoft.Web/sites"
    },
    {
      "apiVersion": "2018-02-01",
      "kind": "linux",
      "location": "northeurope",
      "name": "isaacssuperapp-plan",
      "properties": {
        "name": "isaacssuperapp-plan",
        "perSiteScaling": false,
        "reserved": true
      },
      "sku": {
        "capacity": 1,
        "name": "F1",
        "size": "0",
        "tier": "Free"
      },
      "type": "Microsoft.Web/serverfarms"
    }
  ]
}

Does this look about right?

@forki Please note that you don't specify the password with this approach. Instead, Farmer creates a secure parameter which is passed in at deployment time i.e. when you deploy the template. So this could be passed in by your CI system as an environment variable or whatever.

from farmer.

forki avatar forki commented on August 15, 2024

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@forki that's what I asked you recently - I thought you said that you had tried it and it magically just worked :-)

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

Unless you're referring to the registry credentials url?

from farmer.

forki avatar forki commented on August 15, 2024

Not magically. Only with the properties that I sent you in the private gist

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@forki those are all in the above code snippet?

from farmer.

forki avatar forki commented on August 15, 2024

ok just saw it's the first param of docker_registry_credentials?

Farmer creates a secure parameter which is passed in at deployment time i.e. when you deploy the template

how do I set it?

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

You supply the URL and username at compile time into the Farmer builder (per the example).

The password you have to supply at the runtimetime when calling Deploy.execute. I just realised that in the migration from the REST option, we've dropped that off. Let me add it back in...

from farmer.

forki avatar forki commented on August 15, 2024

;-)

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

Released in 0.11.

let myVm = vm {
    name "isaacssupervm"
    username "isaacadmin"
}

let template = arm {
    location NorthEurope
    add_resource myVm
}

template
|> Deploy.execute "my-resource-group-name" [ "password-for-isaacssupervm", "bladebla" ]

from farmer.

forki avatar forki commented on August 15, 2024

is the docker_ci setting also released? computer says no

from farmer.

dburriss avatar dburriss commented on August 15, 2024

I don't see it in the builder. @isaacabraham seems like a classic "works on my machine" :P

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

Sorry. I was referring to the password bit being release. The Docker stuff not yet - I have literally not tested it at all. Can you test locally from the branch?

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

or provide me with some suitable registry settings :-)

from farmer.

forki avatar forki commented on August 15, 2024

you can test it with the docker hub settings for bookstore

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

The Docker Hub image doesn't need the registry credentials bit - that's the new bit (along with the CI setting). That's just the docker_image setting which is already tested.

from farmer.

JordanMarr avatar JordanMarr commented on August 15, 2024

I'm also interested in creating Azure Container Registry and Container Instances.
Is this still a no, or maybe a maybe? :)

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@JordanMarr definitely yes! ACR is probably a good one to start with as well - here's a sample I found on the official samples github repo: https://github.com/Azure/azure-quickstart-templates/blob/master/101-container-registry/azuredeploy.json.

Happy to provide you to some help as needed.

This would fit nicely with the work that was released this weekend for ACR support in webapps - in the future we could tie them together even more closely so e.g. you create an ACR instance, create a web app, and link the two directly in Farmer.

from farmer.

dburriss avatar dburriss commented on August 15, 2024

@JordanMarr let me know if you are going to pick this up. If not I will. I didn't hear back on whether this work was already started but it sounds like it has not.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@JordanMarr note - when you say "container instances" what do you mean? If you just mean linux app service that use ACR or Docker Hub, then this is already supported. We also have support for Container Groups (although this has not been documented on the site).

from farmer.

JordanMarr avatar JordanMarr commented on August 15, 2024

@JordanMarr note - when you say "container instances" what do you mean? If you just mean linux app service that use ACR or Docker Hub, then this is already supported. We also have support for Container Groups (although this has not been documented on the site).

Ahh, very nice! I think Container Group is actually what I need.

from farmer.

JordanMarr avatar JordanMarr commented on August 15, 2024

@JordanMarr let me know if you are going to pick this up. If not I will. I didn't hear back on whether this work was already started but it sounds like it has not.

Trust that no work here has happened here. :)
Please proceed!

from farmer.

ninjarobot avatar ninjarobot commented on August 15, 2024

@JordanMarr in lieu of it being in the documentation, there is an example in a PR for some tests that shows creating a container group with a single container. I need to revisit with @isaacabraham about what is needed to include this sort of test or if I should do something more to include it in docs. Please let me know if there are some features you would find helpful and they should be easy enough to add.

from farmer.

dburriss avatar dburriss commented on August 15, 2024

@isaacabraham @ninjarobot I would like to take a stab at getting started on this over the weekend. I did look through the builders when I initially asked this question. I may have questions :)
Target:
https://docs.microsoft.com/en-us/azure/templates/microsoft.containerregistry/2017-10-01/registries

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@ninjarobot I'm going to review and get that merged in. Apologies for pushing it to the back.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@dburriss no worries! This is an example of Cognitive Services which is a pretty simple one - you might want to try to follow that one through.

We could also add some technical documentation on how to create new builders / resources.

from farmer.

dburriss avatar dburriss commented on August 15, 2024

@isaacabraham thanks. Let me give it a go and I will make notes of what is not clear to feed into any needed docs.

from farmer.

JordanMarr avatar JordanMarr commented on August 15, 2024

I think you have already ticked all the basic features that I'm using so far in development.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@dburriss my approach has been to do the 20% of functionality that solves 80% of what people want i.e. start simple, release it, and see if anyone complains :-) New features can always be added afterwards without too much work, and I found starting up-front and trying to do everything just over complicates things.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@dburriss one thing that we will probably look at over time is the ability to create a web app and seamlessly connect it to the ACR - so pulling the admin username and password from the ACR resource into the web app as an expression. For now, that's not needed though!

from farmer.

dburriss avatar dburriss commented on August 15, 2024

@isaacabraham addressed the review comment.
I also took at stab at supporting custom storageAccount. That led to noticing a 'Classic' SKU which it turns out is no longer supported. So it turns out a bunch of the additional functionality on ACR is no longer supported.
So the only feature to enable if we wanted to would be Encryption. This can wait for sure till someone requests it.

let deployment = arm {
    location NorthEurope
    add_resource myRegistry
    output "registry" myRegistry.Name
    output "loginServer" (sprintf "[reference(resourceId('Microsoft.ContainerRegistry/registries', '%s'),'2019-05-01').loginServer]" myRegistry.Name.Value)
}

I did want to ask about how to handle outputs from a resource. Was thinking myRegistry.Outputs.LoginServer? I imagine I will need these to get the login details. I think returning these needs to be optional.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

@dburriss I think just create a member on the config object called LoginServer which does the string splicing, similar to how Key works on StorageAccountConfig etc. Then you can just do the following:

let deployment = arm {
    location NorthEurope
    add_resource myRegistry
    output "registry" myRegistry.Name
    output "loginServer" myRegistry.LoginServer

from farmer.

Related Issues (20)

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.