From b2105f361476e1eaea5bf0fa627c2af867e92f55 Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Mon, 13 Feb 2023 11:28:32 +1300 Subject: [PATCH] feat(dockerfile): layered images [EE-4879] (#8301) * multistage build to target production and storybook * missing slash * add storybook for windows too and build targets * feature flag the storybook api * remove kompose and prep for new FF lib * todo comment for FF * update to new feature flags library * simplify logic * fix compilation error * simplified it --- api/portainer.go | 24 +++++++++--------------- build/linux/Dockerfile | 15 +++++++++++++-- build/linux/alpine.Dockerfile | 26 ++++++++++++++++++++++++-- build/windows/Dockerfile | 17 +++++++++++++---- gruntfile.js | 2 +- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/api/portainer.go b/api/portainer.go index bff4de0ec..cad0cb7ce 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -506,9 +506,6 @@ type ( // ExtensionID represents a extension identifier ExtensionID int - // Feature represents a feature that can be enabled or disabled via feature flags - Feature string - // GitlabRegistryData represents data required for gitlab registry to work GitlabRegistryData struct { ProjectID int `json:"ProjectId"` @@ -871,13 +868,13 @@ type ( // A list of label name & value that will be used to hide containers when querying containers BlackListedLabels []Pair `json:"BlackListedLabels"` // Active authentication method for the Portainer instance. Valid values are: 1 for internal, 2 for LDAP, or 3 for oauth - AuthenticationMethod AuthenticationMethod `json:"AuthenticationMethod" example:"1"` - InternalAuthSettings InternalAuthSettings `json:"InternalAuthSettings"` - LDAPSettings LDAPSettings `json:"LDAPSettings"` - OAuthSettings OAuthSettings `json:"OAuthSettings"` - OpenAMTConfiguration OpenAMTConfiguration `json:"openAMTConfiguration"` - FDOConfiguration FDOConfiguration `json:"fdoConfiguration"` - FeatureFlagSettings map[Feature]bool `json:"FeatureFlagSettings"` + AuthenticationMethod AuthenticationMethod `json:"AuthenticationMethod" example:"1"` + InternalAuthSettings InternalAuthSettings `json:"InternalAuthSettings"` + LDAPSettings LDAPSettings `json:"LDAPSettings"` + OAuthSettings OAuthSettings `json:"OAuthSettings"` + OpenAMTConfiguration OpenAMTConfiguration `json:"openAMTConfiguration"` + FDOConfiguration FDOConfiguration `json:"fdoConfiguration"` + FeatureFlagSettings map[featureflags.Feature]bool `json:"FeatureFlagSettings"` // The interval in which environment(endpoint) snapshots are created SnapshotInterval string `json:"SnapshotInterval" example:"5m"` // URL to the templates that will be displayed in the UI when navigating to App Templates @@ -1532,11 +1529,8 @@ const ( WebSocketKeepAlive = 1 * time.Hour ) -// SupportFeatureFlags is a list of supported features. They should all be lower case -// e.g. "microk8s","kaas" -var SupportedFeatureFlags = []featureflags.Feature{ - "microk8s", -} +// List of supported features +var SupportedFeatureFlags = []featureflags.Feature{} const ( _ AuthenticationMethod = iota diff --git a/build/linux/Dockerfile b/build/linux/Dockerfile index 0f9165693..b9ec22765 100644 --- a/build/linux/Dockerfile +++ b/build/linux/Dockerfile @@ -1,4 +1,4 @@ -FROM portainer/base +FROM portainer/base as production LABEL org.opencontainers.image.title="Portainer" \ org.opencontainers.image.description="Docker container management made simple, with the world’s most popular GUI-based container management platform." \ @@ -10,9 +10,19 @@ LABEL org.opencontainers.image.title="Portainer" \ com.docker.extension.publisher-url="https://www.portainer.io" \ com.docker.extension.additional-urls="[{\"title\":\"Website\",\"url\":\"https://www.portainer.io?utm_campaign=DockerCon&utm_source=DockerDesktop\"},{\"title\":\"Documentation\",\"url\":\"https://docs.portainer.io\"},{\"title\":\"Support\",\"url\":\"https://join.slack.com/t/portainer/shared_invite/zt-txh3ljab-52QHTyjCqbe5RibC2lcjKA\"}]" -COPY dist / +COPY dist/docker / +COPY dist/docker-compose / +COPY dist/helm / +COPY dist/kubectl / +COPY dist/mustache-templates /mustache-templates/ +COPY dist/portainer / +COPY dist/public /public/ + COPY build/docker-extension / +# storybook exists only in portainerci builds +COPY dist/storybook* /storybook/ + VOLUME /data WORKDIR / @@ -23,3 +33,4 @@ EXPOSE 8000 LABEL io.portainer.server true ENTRYPOINT ["/portainer"] + diff --git a/build/linux/alpine.Dockerfile b/build/linux/alpine.Dockerfile index 109a8146a..ed04ed342 100644 --- a/build/linux/alpine.Dockerfile +++ b/build/linux/alpine.Dockerfile @@ -1,6 +1,27 @@ -FROM alpine:latest +FROM alpine:latest as production -COPY dist / +LABEL org.opencontainers.image.title="Portainer" \ + org.opencontainers.image.description="Docker container management made simple, with the world’s most popular GUI-based container management platform." \ + org.opencontainers.image.vendor="Portainer.io" \ + com.docker.desktop.extension.api.version=">= 0.2.2" \ + com.docker.desktop.extension.icon="https://portainer-io-assets.sfo2.cdn.digitaloceanspaces.com/logos/portainer.png" \ + com.docker.extension.screenshots="[{\"alt\": \"screenshot one\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-1.png\"},{\"alt\": \"screenshot two\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-2.png\"},{\"alt\": \"screenshot three\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-3.png\"},{\"alt\": \"screenshot four\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-4.png\"},{\"alt\": \"screenshot five\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-5.png\"},{\"alt\": \"screenshot six\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-6.png\"},{\"alt\": \"screenshot seven\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-7.png\"},{\"alt\": \"screenshot eight\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-8.png\"},{\"alt\": \"screenshot nine\", \"url\": \"https://portainer-io-assets.sfo2.digitaloceanspaces.com/screenshots/docker-extension-9.png\"}]" \ + com.docker.extension.detailed-description="

Portainer’s Docker Desktop extension gives you access to all of Portainer’s rich management functionality within your docker desktop experience.

With Portainer you can:

About Portainer 

Portainer is the worlds’ most popular universal container management platform with more than 650,000 active monthly users. Portainer can be used to manage Docker Standalone, Kubernetes, Docker Swarm and Nomad environments through a single common interface. It includes a simple GitOps automation engine and a Kube API. 

Portainer Business Edition is our fully supported commercial grade product for business-wide use. It includes all the functionality that businesses need to manage containers at scale. Visit Portainer.io to learn more about Portainer Business and get 5 free nodes.

" \ + com.docker.extension.publisher-url="https://www.portainer.io" \ + com.docker.extension.additional-urls="[{\"title\":\"Website\",\"url\":\"https://www.portainer.io?utm_campaign=DockerCon&utm_source=DockerDesktop\"},{\"title\":\"Documentation\",\"url\":\"https://docs.portainer.io\"},{\"title\":\"Support\",\"url\":\"https://join.slack.com/t/portainer/shared_invite/zt-txh3ljab-52QHTyjCqbe5RibC2lcjKA\"}]" + +COPY dist/docker / +COPY dist/docker-compose / +COPY dist/helm / +COPY dist/kubectl / +COPY dist/mustache-templates /mustache-templates/ +COPY dist/portainer / +COPY dist/public /public/ + +COPY build/docker-extension / + +# storybook exists only in portainerci builds +COPY dist/storybook* /storybook/ VOLUME /data WORKDIR / @@ -12,3 +33,4 @@ EXPOSE 8000 LABEL io.portainer.server true ENTRYPOINT ["/portainer"] + diff --git a/build/windows/Dockerfile b/build/windows/Dockerfile index ccdc74682..ab27d7eb9 100644 --- a/build/windows/Dockerfile +++ b/build/windows/Dockerfile @@ -5,10 +5,10 @@ ENV GIT_VERSION 2.30.0 ENV GIT_PATCH_VERSION 2 RUN mkdir mingit/ \ -&& wget https://github.com/git-for-windows/git/releases/download/v$GIT_VERSION.windows.$GIT_PATCH_VERSION/MinGit-$GIT_VERSION.$GIT_PATCH_VERSION-busybox-64-bit.zip \ -&& unzip MinGit-$GIT_VERSION.$GIT_PATCH_VERSION-busybox-64-bit.zip -d mingit/ + && wget https://github.com/git-for-windows/git/releases/download/v$GIT_VERSION.windows.$GIT_PATCH_VERSION/MinGit-$GIT_VERSION.$GIT_PATCH_VERSION-busybox-64-bit.zip \ + && unzip MinGit-$GIT_VERSION.$GIT_PATCH_VERSION-busybox-64-bit.zip -d mingit/ -FROM mcr.microsoft.com/windows/nanoserver:${OSVERSION} +FROM mcr.microsoft.com/windows/nanoserver:${OSVERSION} as production ENV PATH "C:\mingit\cmd;C:\Windows\system32;C:\Windows;" COPY --from=downloader /mingit mingit/ @@ -16,7 +16,16 @@ COPY --from=core /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll USER ContainerAdministrator -COPY dist / +COPY dist/docker.exe / +COPY dist/docker-compose.exe / +COPY dist/helm.exe / +COPY dist/kubectl.exe / +COPY dist/mustache-templates /mustache-templates/ +COPY dist/portainer.exe / +COPY dist/public /public/ + +# storybook exists only in portainerci builds +COPY dist/storybook* /storybook/ EXPOSE 9000 EXPOSE 9443 diff --git a/gruntfile.js b/gruntfile.js index 892d0c509..e96d57921 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -124,7 +124,7 @@ gruntConfig.shell = { }; function shell_storybook(env) { - if (env === 'production') { + if (env === 'prod') { return ''; }