-
Notifications
You must be signed in to change notification settings - Fork 30
🆕 Devcontainer support, Docker support and IPv6 inside container fix #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2b92213
121dee7
d8e7f27
540968c
55f404a
0a72c77
6cc45bf
d5f37a3
8be8cfa
807db30
2a4d874
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "slrp dev", | ||
| "image": "mcr.microsoft.com/devcontainers/go:1-1.20-bookworm", | ||
| "postCreateCommand": ".devcontainer/postcreate.sh", | ||
| "remoteUser": "root", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "foxundermoon.shell-format", | ||
| "GitHub.copilot", | ||
| "eamodio.gitlens", | ||
| "ms-vscode.makefile-tools", | ||
| "ms-azuretools.vscode-docker" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
| NVM_VERSION="0.38.0" | ||
| NODE_VERSION="20" | ||
|
|
||
| # # If you're developing in a container behind a VPNed/MDM-managed machine you might get "self signed certs in chain" error. | ||
| # # This snippet below bypasses that (ssl is required later for nvm installation) | ||
| # apt update && apt install -y git | ||
| # git config --global http.sslVerify false | ||
|
|
||
| echo "[ + ] Running post-create script. Installing the following:" | ||
| echo "[ + ] NVM version: $NVM_VERSION" | ||
| echo "[ + ] NodeJS version: $NODE_VERSION" | ||
| echo "[ + ] ==============================" | ||
|
|
||
| # Check if we don't have nvm, if no - install it | ||
| echo "[ + ] Installing nvm at v$NVM_VERSION" | ||
|
|
||
| curl -k -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash | ||
| # Activate nvm | ||
| export NVM_DIR="$HOME/.nvm" | ||
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
|
||
| # Refresh bash | ||
| source ~/.bashrc | ||
|
|
||
| # Install node at a set versions | ||
| echo "[ + ] Installing NodeJS at v$NODE_VERSION" | ||
| nvm install $NODE_VERSION && nvm use $NODE_VERSION | ||
|
|
||
| echo "[ + ] Installing UI dependencies and building..." | ||
| # Change to the "ui" directory | ||
| cd ui && npm install && cd ../ | ||
|
|
||
| echo "[ + ] Installing Go dependencies and building..." | ||
| make build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| // Run the main.go program | ||
| { | ||
| "name": "Launch Package", | ||
| "type": "go", | ||
| "request": "launch", | ||
| "mode": "debug", | ||
| "program": "${workspaceFolder}/main.go", | ||
| "env": {}, | ||
| "args": [] | ||
| }, | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,34 @@ | ||
| FROM alpine | ||
| # Install node and deps to build the frontend | ||
| FROM node:20.11-bookworm AS NODE_INSTALL | ||
| WORKDIR /app | ||
| COPY . . | ||
| RUN npm --prefix ui install && \ | ||
| npm --prefix ui run build | ||
|
|
||
| ENV PWD="/app" | ||
| # Install go and deps to build the backend | ||
| FROM golang:1.20.13-bookworm AS BUILD | ||
| WORKDIR /app | ||
| COPY --from=NODE_INSTALL /app . | ||
| RUN make build-go-for-docker | ||
|
|
||
| # Final image | ||
| FROM alpine:latest | ||
| # SLRP configuration environment variables | ||
| ENV SLRP_APP_STATE="$PWD/.slrp/data" | ||
| ENV SLRP_APP_SYNC="1m" | ||
| ENV SLRP_LOG_LEVEL="info" | ||
| ENV SLRP_LOG_FORMAT="pretty" | ||
| ENV SLRP_SERVER_ADDR="0.0.0.0:8089" | ||
| ENV SLRP_SERVER_READ_TIMEOUT="15s" | ||
| ENV SLRP_MITM_ADDR="0.0.0.0:8090" | ||
| ENV SLRP_MITM_READ_TIMEOUT="15s" | ||
| ENV SLRP_MITM_IDLE_TIMEOUT="15s" | ||
| ENV SLRP_MITM_WRITE_TIMEOUT="15s" | ||
| ENV SLRP_CHECKER_TIMEOUT="5s" | ||
| ENV SLRP_CHECKER_STRATEGY="simple" | ||
| ENV SLRP_HISTORY_LIMIT="1000" | ||
|
|
||
| WORKDIR $PWD | ||
| COPY slrp $PWD | ||
|
|
||
| RUN mkdir ./.slrp | ||
|
|
||
| ENV SLRP_APP_STATE="/opt/.slrp/data" \ | ||
| SLRP_APP_SYNC="1m" \ | ||
| SLRP_LOG_LEVEL="info" \ | ||
| SLRP_LOG_FORMAT="pretty" \ | ||
| SLRP_SERVER_ADDR="0.0.0.0:8089" \ | ||
| SLRP_SERVER_READ_TIMEOUT="15s" \ | ||
| SLRP_MITM_ADDR="0.0.0.0:8090" \ | ||
| SLRP_MITM_READ_TIMEOUT="15s" \ | ||
| SLRP_MITM_IDLE_TIMEOUT="15s" \ | ||
| SLRP_MITM_WRITE_TIMEOUT="15s" \ | ||
| SLRP_CHECKER_TIMEOUT="5s" \ | ||
| SLRP_CHECKER_STRATEGY="simple" \ | ||
| SLRP_HISTORY_LIMIT="1000" | ||
| WORKDIR /opt | ||
| COPY --from=BUILD /app/main /opt/slrp | ||
| RUN mkdir -p ./.slrp/data | ||
| EXPOSE 8089 8090 | ||
|
|
||
| CMD ["./slrp"] | ||
| CMD ["/opt/slrp"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,14 @@ build: build-ui | |
| go mod vendor | ||
| go build -ldflags "-s -w" main.go | ||
|
|
||
| # When running inside Alpine images there are no classic OS packages/binaries enabled, hence - we compile statically (CGO) | ||
| build-go-for-docker: | ||
| go mod vendor | ||
| CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-s -w" -o main main.go | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use cgo here at all, pls remove
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, tho when running the project on Alpine it fails unless compiling w/ CGO.
wdyt?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the situation where a code comment could have avoided a review comment 😉
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add the comment where needed ;) |
||
|
|
||
| docker: | ||
| docker build -t slrp:latest . | ||
|
|
||
| quick: | ||
| go build | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w/o the container can't init
nvm(runsource ~/.bashrc) properly.Since this is only for the devcontainer, I think it's fine security-wise