Trying to upgrade assets canister on IC network?

Hello!

I want to upgrade to a new version of an asset canister (website) to main IC network, but failing to do so, since DFX says everything is already installed. I, however, have changed CSS styles and the code is not the same (but it seems dfx does not know how to figure out that there was a change in code of the main.css file and it’s not the same as it was earlier.
Command I’ve ran is:
dfx canister --network ic install deck_website_assets --mode upgrade

And the output is:

Upgrading code for canister deck_website_assets, with canister_id epmcs-xxxx-xxxxx-xxxxx
Module hash e0df779f65fe44893d8991bef0f9af442bff019b79ec756eface2b58beec236f is already installed.
Authorizing our identity (default) to the asset canister...
Uploading assets to asset canister...
Starting batch.
Staging contents of new and changed assets:
  /index.html (2563 bytes) sha 7b63fe0a6b817d946dbf56073990ae2bf15989c2a87bf8f7e06f2b97440d4c2c is already installed
  /index.html (gzip) (931 bytes) sha 24061b64f209e35ca0b503eb7151acc7fe9824917b117e50f6fbc8864264d261 is already installed
  /index.js (0 bytes) sha e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 is already installed
  /main.scss (3591 bytes) sha 4cb032198facbc9af55be533fba761f6c4f15804a8df923ad1d908f4f37021af is already installed
  /main.scss (gzip) (909 bytes) sha f2ed311f24f829dc1397a6123d3c2cf01059416d3d65c81c6f0b602f238c673a is already installed
  /fonts/UnZialish.ttf (59900 bytes) sha e2543f2407207b84d11558e923dcc255a1c6368f2ecc1e3415a521e8af069f5b is already installed
  /fonts/made-in-china.regular.ttf (28488 bytes) sha 108e9b0321b15eb38916c4314c441612b966130b849a3bf8507ce44e9c3981ec is already installed
  /images/deck_swap.png (22537 bytes) sha add6035e89d80c956277112844112bc7cddbfbb4c50920b14c8d371ed976cd78 is already installed
  /images/background.jpg (190672 bytes) sha 50f224d697a31ea860eefc6ab0151e424141bdcaa2d7fbb53eba613227e63111 is already installed
  /images/cards.png (83573 bytes) sha 95a6e062dd411ddca741c3182d88d7b6ecb149f7d63261d2f1c809a8d527341b is already installed
  /images/social_icons_sprite.png (7998 bytes) sha 410244cde2285ec2e2b2d256cf170e7bfc095b235070646e40ba6251c173115c is already installed
  /images/first_nft.png (8842 bytes) sha 637f1bb268f1e23a5ece07f4c7f3b8712b595c6d2798ae39a3b3c90c74528f8f is already installed
  /images/timeline.png (4854 bytes) sha c7f9b350117f293a9f1e422e95327526692b9012699327fe7651690b791223ee is already installed
  /images/ddeck_tower.png (168131 bytes) sha 3ad4f7d9f38e1edc930adb8c4091226acd3951ac8dbb6d5b3d0f9df72e0ce8ae is already installed
  /images/paradigm.png (22321 bytes) sha aa9df3ef199de46d97cc4c22581995503da79a7b012cb7cc47111ed4e3cafe3e is already installed
  /images/elements.png (20615 bytes) sha 0422cbe6fa44b8436829d6ef223d749407eeafcaab9d341725d66a91e35fdb43 is already installed
  /images/digms.png (39896 bytes) sha 3cb4fb3498285dc2ffaed7e35e44e76361e00e059928747cd6571dbf6549e638 is already installed
  /main.css (164905 bytes) sha 71d5e8b90142e01d30848b1937db9f0dfe3dff52b1bbcd0ff569a50711b17ed4 is already installed
  /main.css (gzip) (24252 bytes) sha aa665825017af1731c7c74039ff72f200c961a03e9253767507f4276f26ba4cc is already installed
  /favicon.ico (15406 bytes) sha 4e8d31b50ffb59695389d94e393d299c5693405a12f6ccd08c31bcf9b58db2d4 is already installed
Committing batch.

Can someone explain to me if I am doing something wrong and how we could update assset canister ?

Have you tried the deploy command?
I think you need to build first which is done by the deploy command

1 Like

Instructions in the docs don’t mention anything about deploying though. I will check it out now, thank you

Unfortunatelly, that is not possible since canister already exists (it has already been created the first time deploy was ran)

I’ve tried doing:
dfx canister --network ic install deck_website_assets --mode reinstall

To drop all code and state (which I don’t have, since it’s a website, no SC code) and everything went through this time, but no changes were made still. I hear ICP uses gzip for assets, is there a time period I would have to wait until the old gzipped assets are purged to see my changes or?

dfx canister --network ic install deck_website_assets --mode reinstall
Warning!
You are about to reinstall the deck_website_assets canister.
This will OVERWRITE all the data and code in the canister.

YOU WILL LOSE ALL DATA IN THE CANISTER.

Do you want to proceed? yes/No
yes
Reinstalling code for canister deck_website_assets, with canister_id epmcs-xxxxx-xxxxx-xxxxx-cai
Authorizing our identity (default) to the asset canister...
Uploading assets to asset canister...
Starting batch.
Staging contents of new and changed assets:
  /index.html 1/1 (2563 bytes)
  /index.html (gzip) 1/1 (931 bytes)
  /index.js 1/1 (0 bytes)
  /main.scss 1/1 (3591 bytes)
  /main.scss (gzip) 1/1 (909 bytes)
  /fonts/UnZialish.ttf 1/1 (59900 bytes)
  /fonts/made-in-china.regular.ttf 1/1 (28488 bytes)
  /images/deck_swap.png 1/1 (22537 bytes)
  /images/background.jpg 1/1 (190672 bytes)
  /images/cards.png 1/1 (83573 bytes)
  /images/social_icons_sprite.png 1/1 (7998 bytes)
  /images/first_nft.png 1/1 (8842 bytes)
  /images/timeline.png 1/1 (4854 bytes)
  /images/ddeck_tower.png 1/1 (168131 bytes)
  /images/paradigm.png 1/1 (22321 bytes)
  /images/elements.png 1/1 (20615 bytes)
  /images/digms.png 1/1 (39896 bytes)
  /main.css 1/1 (164905 bytes)
  /main.css (gzip) 1/1 (24252 bytes)
  /favicon.ico 1/1 (15406 bytes)
Committing batch.

There’s a build step that coin_master mentioned which you may be missing? Try:

dfx build deck_website_assets

then

dfx canister --network ic install deck_website_assets

dfx deploy actually combines these two into a single command.

Thanks for trying to help! :slight_smile:

I have tried deploy as well before trying to upgrade already deployed canister (command you posted would just deploy a completely new canister with a new canister ID on the network, which I don’t currently want to do, since I already have deployed first version of it and would like to keep the canister ID the same, only upgrade it’s code to the latest one). Whenever I want to use the

dfx canister -network ic install deck_website_assets --mode upgrade
I get “already installed” for each of the assets in the canister, which means it’s not actually changing any assets of it (even though for example main.css file has been changed and code in it is not the same as it is currently in the deployed canister).

When I try doing a reinstall (that would also keep the canister ID the same and remove all the previous code and assets from it) with command
dfx canister --network ic install deck_website_assets --mode reinstall

everything seems to go through properly, you can see output of the command above in one of my comments on this post, but the changes are not actually made since the website looks exactly the same as before and has no updated main.css code in it.

Is there any way of accomplishing what I want to accomplish (upgrade or reinstall already deployed frontend assets canister without actually deploying a brand new canister with a new canister ID), or will I have to just abandon the current canister altogether, destroy it and deploy a new canister with the current code on the new address?

Are you able to build and update changes to the canister on a local replica (without the --network ic flag)?

[email protected]:/var/icp/deck_website$ dfx build deck_website_assets

Building canisters...

Building frontend...

That’s the output I get when using build localy

After that I try to do

dfx canister -network ic install deck_website_assets --mode upgrade
or
dfx canister --network ic install deck_website_assets --mode reinstall

and the above mentioned occurs for each

Seems that the solution is just using regular deploy command on the IC. It probably picks up canister id from canister_ids.json file in the folder root and then actually upgrades the same canister that was already deployed, instead of just deploying a brand new one on a new address. So,running:

dfx deploy deck_webiste_assets --network ic

is the way to upgrade the canister at the same IC address.