Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm

RUN apt update
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the standard way to do this? This packages a layer of "latest" (build time) package list, can't the user just run this themselves if they want extra packages?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's non-standard, just different. I had changed it from the default in the devcontainer.json because I thought there might be other stuff that needed to be added on top of the base image, but that ended up not being the case. I'll change this back.

9 changes: 9 additions & 0 deletions .devcontainer/config-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

make download-tools
go get
yarn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem right, it should be only one yarn

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are additional go dependencies that are downloaded during a go run/build that aren't downloaded by make download-tools, so this pre-caches them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. Only the yarn inside the ui directory is needed. I'll fix that.


cd ui
yarn
yarn build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK you should not try to build the actual code in environment setup (it seems like the template you are using also says use this to "download required toolchains"), as that can cause breakage if the code stops building.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base template didn't include any of this, I wrote all this myself. Technically this all happens after the container image is built as a post-build action.

24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Gotify Server Dev Container",
//"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/go:1": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Download required toolchains with `make` and `yarn`
"postCreateCommand": "bash .devcontainer/config-environment.sh",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
//root needed because server runs on port 80 and `yarn build` fails without it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just set GOTIFY_SERVER_PORT environment variable instead of running as root?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, honestly didn't try that. Will test it out.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn build still fails though without root, not sure how critical this error is, I'm not a node person myself

node ➜ /workspaces/server/ui (master) $ yarn build
yarn run v1.22.22
$ tsc
$ vite build
vite v7.0.6 building for production...
✓ 12120 modules transformed.
✗ Build failed in 13.74s
error during build:
EACCES: permission denied, unlink '/workspaces/server/ui/build/static/PluginDetailView-Dsl1DMbT.js'
    at unlinkSync (node:fs:1953:11)
    at _unlinkSync (node:internal/fs/rimraf:215:14)
    at rimrafSync (node:internal/fs/rimraf:196:7)
    at node:internal/fs/rimraf:254:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:251:7)
    at rimrafSync (node:internal/fs/rimraf:194:7)
    at Object.rmSync (node:fs:1248:10)
    at emptyDir (file:///workspaces/server/ui/node_modules/vite/dist/node/chunks/dep-BHkUv4Z8.js:2516:11)
    at prepareOutDir (file:///workspaces/server/ui/node_modules/vite/dist/node/chunks/dep-BHkUv4Z8.js:34153:4)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

"remoteUser": "root"
}