{"id":15858949,"url":"https://github.com/bpmct/v2-docker-local-builds","last_synced_at":"2026-03-18T17:03:37.144Z","repository":{"id":117906783,"uuid":"492981077","full_name":"bpmct/v2-docker-local-builds","owner":"bpmct","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-17T13:53:12.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T12:49:03.645Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bpmct.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-16T19:57:04.000Z","updated_at":"2022-05-17T13:53:15.000Z","dependencies_parsed_at":"2023-03-11T15:45:20.600Z","dependency_job_id":null,"html_url":"https://github.com/bpmct/v2-docker-local-builds","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"64f6b22d97c73bb7bc59efb906e6cd0117f4f683"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpmct%2Fv2-docker-local-builds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpmct%2Fv2-docker-local-builds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpmct%2Fv2-docker-local-builds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpmct%2Fv2-docker-local-builds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpmct","download_url":"https://codeload.github.com/bpmct/v2-docker-local-builds/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246705404,"owners_count":20820725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T21:02:14.539Z","updated_at":"2026-01-11T01:41:57.433Z","avatar_url":"https://github.com/bpmct.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nname: Develop in Docker with custom image builds\ndescription: Builds images on the Docker host, no registry required\ntags: [local, docker]\n---\n\n# docker-image-builds\n\nThis example bundles Dockerfiles in the Coder template, allowing the Docker host to build images itself\ninstead of relying on an external registry.\n\nFor large use cases, we recommend building images using CI/CD pipelines and registries instead of at workspace \"runtime.\" However, this example is practical for tinkering and iterating on Dockerfiles.\n\n## Getting started\n\nSelect this template in `coder templates init` and follow instructions. \n\n## Adding images\n\nCreate a Dockerfile (e.g `images/golang.Dockerfile`)\n\n```sh\nvim images/golang.Dockerfile\n```\n\n```Dockerfile\n# Start from base image (built on Docker host)\nFROM coder-base:latest\n\n# Install everything as root\nUSER root\n\n# Install go\nRUN curl -L \"https://dl.google.com/go/go1.17.1.linux-amd64.tar.gz\" | tar -C /usr/local -xzvf -\n\n# Setup go env vars\nENV GOROOT /usr/local/go\nENV PATH $PATH:$GOROOT/bin\n\nENV GOPATH /home/coder/go\nENV GOBIN $GOPATH/bin\nENV PATH $PATH:$GOBIN\n\n# Set back to coder user\nUSER coder\n```\n\nEdit the template Terraform (`main.tf`)\n\n```sh\nvim main.tf\n```\n\nEdit the validation to include the new image:\n\n```diff\nvariable \"docker_image\" {\n    description = \"What docker image would you like to use for your workspace?\"\n    default     = \"base\"\n\n    # List of images available for the user to choose from.\n    # Delete this condition to give users free text input.\n    validation {\n-       condition     = contains([\"base\", \"java\", \"node\"], var.docker_image)\n+       condition     = contains([\"base\", \"java\", \"node\", \"golang], var.docker_image)\n        error_message = \"Invalid Docker Image!\"\n    }\n}\n```\n\nBump the image tag to a new version:\n\n```diff\nresource \"docker_image\" \"coder_image\" {\n    name = \"coder-base-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}\"\n    build {\n        path       = \"./images/\"\n        dockerfile = \"${var.docker_image}.Dockerfile\"\n-        tag        = [\"coder-${var.docker_image}:v0.1\"]\n+        tag        = [\"coder-${var.docker_image}:v0.2\"]\n    }\n\n    # Keep alive for other workspaces to use upon deletion\n    keep_locally = true\n}\n```\n\nUpdate the template:\n\n```sh\ncoder template update docker-image-builds\n```\n\n## Updating images\n\nEdit the Dockerfile (or related assets)\n\n```sh\nvim images/node.Dockerfile\n```\n\n```diff\n# Install Node\n- RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -\n+ RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -\nRUN DEBIAN_FRONTEND=\"noninteractive\" apt-get update -y \u0026\u0026 \\\n    apt-get install -y nodejs\n```\n\n1. Edit the template Terraform (`main.tf`)\n\n```sh\nvim main.tf\n```\n\nBump the image tag to a new version:\n\n```diff\nresource \"docker_image\" \"coder_image\" {\n    name = \"coder-base-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}\"\n    build {\n        path       = \"./images/\"\n        dockerfile = \"${var.docker_image}.Dockerfile\"\n-        tag        = [\"coder-${var.docker_image}:v0.1\"]\n+        tag        = [\"coder-${var.docker_image}:v0.2\"]\n    }\n\n    # Keep alive for other workspaces to use upon deletion\n    keep_locally = true\n}\n```\n\nUpdate the template:\n\n```sh\ncoder template update docker-image-builds\n```\n\nOptional: Update workspaces to the latest template version\n\n```sh\ncoder ls\ncoder update [workspace name]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpmct%2Fv2-docker-local-builds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpmct%2Fv2-docker-local-builds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpmct%2Fv2-docker-local-builds/lists"}