code-server icon indicating copy to clipboard operation
code-server copied to clipboard

How to install extensions while building docker image

Open majikxu opened this issue 7 years ago • 11 comments

Could I install extensions over cli? Or during docker image building?

majikxu avatar Apr 11 '19 08:04 majikxu

ciao @yamajik

have a look at our Dockerfile at https://github.com/monostream/code-server/blob/develop/Dockerfile at the end of the file. We download the VSIX from the marketplace and extract it to the extensions folder. make sure you use bsdtar for this

cheers

adrianliechti avatar Apr 11 '19 12:04 adrianliechti

ciao @yamajik

have a look at our Dockerfile at https://github.com/monostream/code-server/blob/develop/Dockerfile at the end of the file. We download the VSIX from the marketplace and extract it to the extensions folder. make sure you use bsdtar for this

cheers

ENV HOME_DIR "/root"

# Setup User Visual Studio Code Extentions
ENV CODE_SERVER_EXTENSIONS "${HOME_DIR}/.local/share/code-server/extensions"

# Setup User Visual Studio Code Workspace Storage
ENV CODE_SERVER_WORKSPACESTORAGE "${HOME_DIR}/.code-server/User/workspaceStorage"

# Mkdir Workspace Storage
RUN mkdir -p ${CODE_SERVER_WORKSPACESTORAGE}

# Setup Python Extension
RUN mkdir -p ${CODE_SERVER_EXTENSIONS}/python \
 && curl -JLs --retry 5 https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/python/latest/vspackage | bsdtar --strip-components=1 -xf - -C ${CODE_SERVER_EXTENSIONS}/python extension
bsdtar: Error opening archive: Unrecognized archive format

whats wrong?

majikxu avatar Apr 12 '19 16:04 majikxu

@yamajik The official VSCode extensions are not distributed in Tar format, they are Zips.

foresthoffman avatar Apr 12 '19 16:04 foresthoffman

@yamajik i recognized this as well from time to time while building the image... it seems the marketplace fails deliver the vsix file somwtime

a repeating docker build usually works... and since docker is caching the layers, it takes not as long as the first time

adrianliechti avatar Apr 12 '19 17:04 adrianliechti

i have

@yamajik i recognized this as well from time to time while building the image... it seems the marketplace fails deliver the vsix file somwtime

a repeating docker build usually works... and since docker is caching the layers, it takes not as long as the first time

find it too and terriable it is. i have to build 60 different images every update time and retry for max 3 times on each building. still failed sometimes 🤦‍♀️

majikxu avatar Apr 13 '19 07:04 majikxu

this is the error of a failed download:

{"$id":"1","innerException":null,"message":"Anonymous usage from IP address xxx.xxx.xxx.xxx has exceeded our rate limits and is being blocked. Anonymous access from this IP address will be unblocked within the next 1 minute. You can also consider logging in to get unblocked. Logged in users have higher limits. Learn more: https://go.microsoft.com/fwlink/?LinkId=823950.","typeName":"Microsoft.TeamFoundation.Framework.Server.RequestBlockedException, Microsoft.TeamFoundation.Framework.Server","typeKey":"RequestBlockedException","errorCode":0,"eventId":3000}

adrianliechti avatar Apr 14 '19 19:04 adrianliechti

@adrianliechti That's because the Microsoft VSCode Extension Marketplace API is not public. Using it in this way is against their TOS.

foresthoffman avatar Apr 15 '19 15:04 foresthoffman

this is the error of a failed download:

{"$id":"1","innerException":null,"message":"Anonymous usage from IP address xxx.xxx.xxx.xxx has exceeded our rate limits and is being blocked. Anonymous access from this IP address will be unblocked within the next 1 minute. You can also consider logging in to get unblocked. Logged in users have higher limits. Learn more: https://go.microsoft.com/fwlink/?LinkId=823950.","typeName":"Microsoft.TeamFoundation.Framework.Server.RequestBlockedException, Microsoft.TeamFoundation.Framework.Server","typeKey":"RequestBlockedException","errorCode":0,"eventId":3000}

It also makes extensionquery error. Couldn't install other exts. Screen Shot 2019-04-16 at 15 03 06

majikxu avatar Apr 16 '19 07:04 majikxu

Can now be done reasonably cleanly with changes from #504. There are no docs on this yet afaik.

lucacasonato avatar Apr 18 '19 09:04 lucacasonato

@foresthoffman are you sure? I ask because if you navigate to https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp for example, you find on the right side a "Download Extension" link in the section of "Resources"... looks pretty public to me...

adrianliechti avatar Apr 18 '19 11:04 adrianliechti

@yamajik This is expected. Please see my comment to @adrianliechti below.

@lucacasonato Yes, thank you. That addition to the CLI will make this much more achievable.

@adrianliechti I am absolutely certain. Using an HTTP(S) client to access the Microsoft servers and download an extension is completely different from using an API with documented endpoints, required request values, and expected response values.

@adrianliechti That's because the Microsoft VSCode Extension Marketplace API is not public. Using it in this way is against their TOS.

Since the original question was regarding installing extensions via the CLI, and #504 has fixed this, i'll be closing this issue. Thank you.

foresthoffman avatar Apr 18 '19 15:04 foresthoffman