TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ko: Easy Go Containers

113 点作者 bamazizi超过 1 年前

8 条评论

ImJasonH超过 1 年前
Hey, ko maintainer here! I&#x27;d love to answer any questions or hear any feedback folks have.<p>Ko&#x27;s simplicity comes from focusing on doing exactly one thing well -- it doesn&#x27;t have to run containers to build code in any language, it just builds minimal Go containers, and that means it can focus on doing that as well as possible.<p>Another powerful benefit of focusing on Go (IMO) is that ko can be used to transform a Go importpath to a built image reference.<p>A common simple use: `docker run $(ko build .&#x2F;cmd&#x2F;app)`<p>This is also how Kubernetes YAML templating[1] works, and it&#x27;s also how the Terraform provider[2] works -- you give it an importpath, and ko transforms it into a built image reference you can pass to the rest of your config. I don&#x27;t even &quot;use ko&quot; day-to-day most days, I mostly just use terraform. :)<p>1: <a href="https:&#x2F;&#x2F;ko.build&#x2F;features&#x2F;k8s&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;ko.build&#x2F;features&#x2F;k8s&#x2F;</a> 2: <a href="https:&#x2F;&#x2F;ko.build&#x2F;advanced&#x2F;terraform&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;ko.build&#x2F;advanced&#x2F;terraform&#x2F;</a>
评论 #38216743 未加载
评论 #38190288 未加载
Cyphase超过 1 年前
For those who don&#x27;t know: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Ko_fight" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Ko_fight</a>
flimsypremise超过 1 年前
I&#x27;ll be honest, I just don&#x27;t think this is a great way to do development in any language:<p>`ko builds images by executing go build on your local machine`<p>If you&#x27;ve done any sort of work with service or application development on a team, you will no doubt have encountered issues with relying on local machine build dependencies. Enforcing dependency versions across the team is basically impossible even in cases where the entire team is using the same OS and hardware, so you&#x27;re going to run into problems where users are building the codebase with different versions of tools and dependencies. This is one of the core problems that containerization was intended to solve, so if you are using containerization in development and not building inside the container, you are missing out on one of the major advantages of the paradigm.
评论 #38192027 未加载
评论 #38191950 未加载
hknmtt超过 1 年前
I have used something like this in the past:<p>FROM alpine:latest AS base # Scratch does not have shell so we have to create non-root user in here and later copy it into scratch. RUN adduser -D -u 123456 appusr<p>FROM scratch # Copy the binary. COPY foo.bin &#x2F;foo.bin # Copy the user and set is as active. COPY --from=base &#x2F;etc&#x2F;passwd &#x2F;etc&#x2F;passwd USER appusr # Non-root user cannot bind to &quot;privileged&quot; ports(&lt;=1024). EXPOSE 1234 ENTRYPOINT [&quot;&#x2F;foo.bin&quot;]<p>Simple. But i can see ko being good alternative if you for some reason do not want to install docker on your computer but still be able to build docker containers.
评论 #38190687 未加载
评论 #38195608 未加载
评论 #38190095 未加载
评论 #38189157 未加载
评论 #38187779 未加载
riv991超过 1 年前
I love ko, so simple to get a container running in one line and now integrated with GoReleaser.<p>`docker run $(ko build -L main.go)`
ithkuil超过 1 年前
I love `ko`. I wish there was something similar for rust but I haven&#x27;t found it quite yet
评论 #38190185 未加载
评论 #38189491 未加载
评论 #38192051 未加载
评论 #38190196 未加载
pachico超过 1 年前
Dammit, why didn&#x27;t I know about this? In general, I always have the feeling I&#x27;m not aware of great applications out there, and I confirm this sensation every time I find them, like now!<p>How do you all stay tune of the great apps out there?
评论 #38190930 未加载
评论 #38190491 未加载
avtolik超过 1 年前
I am building an app right now and looked into this. Unfortunately the support for including static assets is limited for my case.
评论 #38191175 未加载
评论 #38192408 未加载