FROM mcr.microsoft.com/vscode/devcontainers/base:0-focal
+ARG NONROOT_USER=vscode
-# ** [Optional] Uncomment this section to install additional packages. **
-# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
-# && apt-get -y install --no-install-recommends <your-package-list-here>
-
-RUN apt update -y && apt install apt-transport-https curl gnupg python build-essential ca-certificates lsb-release -y && \
+# Install required programs for the container
+RUN apt update -y && apt install apt-transport-https curl sudo gnupg python build-essential ca-certificates lsb-release -y && \
+ # Add bazel repository gpg keys
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/bazel.gpg && \
+ # Add docker repository gpg keys
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
+ # Add docker repository apt source
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list && \
+ # Add bazel repository apt source
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
+ # Install bazel tools
+ curl -L https://github.com/bazelbuild/buildtools/releases/download/4.2.0/buildifier -o /usr/bin/buildifier && \
+ curl -L https://github.com/bazelbuild/buildtools/releases/download/4.2.0/buildozer-linux-amd64 -o /usr/bin/buildozer && \
+ chmod +x /usr/bin/buildifier && chmod +x /usr/bin/buildozer && \
+ # Install docker & bazel
apt update -y && apt install bazel docker-ce-cli -y
-ARG NONROOT_USER=vscode
+# Add the user to the sudo group
+RUN adduser $NONROOT_USER sudo
+# Allow to use sudo without password
+RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+# Startup script, configure docker for the container non-root user
RUN echo "#!/bin/sh\n\
+ . ~/.cargo/env\n\
SOCKET_GID=\$(stat -c '%g' /var/run/docker.sock) \n\
if [ \"${SOCKET_GID}\" != '0' ]; then\n\
- if [ \"\$(cat /etc/group | grep :\${SOCKET_GID}:)\" = '' ]; then groupadd --gid \${SOCKET_GID} docker-host; fi \n\
- if [ \"\$(id ${NONROOT_USER} | grep -E \"groups=.*(=|,)\${SOCKET_GID}\(\")\" = '' ]; then usermod -aG \${SOCKET_GID} ${NONROOT_USER}; fi\n\
+ if [ \"\$(cat /etc/group | grep :\${SOCKET_GID}:)\" = '' ]; then sudo groupadd --gid \${SOCKET_GID} docker-host; fi \n\
+ if [ \"\$(id ${NONROOT_USER} | grep -E \"groups=.*(=|,)\${SOCKET_GID}\(\")\" = '' ]; then sudo usermod -aG \${SOCKET_GID} ${NONROOT_USER}; fi\n\
fi\n\
exec \"\$@\"" > /usr/local/share/docker-init.sh \
&& chmod +x /usr/local/share/docker-init.sh
+USER $NONROOT_USER
+
+# Install go & rust toolchains
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly -y && \
+ curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash
+
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
-CMD [ "sleep", "infinity" ]
\ No newline at end of file
+# Required for vscode to start the server inside the container
+CMD [ "sleep", "infinity" ]
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
- ""
+ "matklad.rust-analyzer",
+ "bazelbuild.vscode-bazel",
+ "vadimcn.vscode-lldb",
+ "ms-azuretools.vscode-docker",
+ "golang.go",
+ "ms-kubernetes-tools.vscode-kubernetes-tools",
+ "zxh404.vscode-proto3",
+ "phgn.vscode-starlark",
+ "redhat.vscode-yaml"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
with:\r
name: all-${{ matrix.os }}\r
path: |\r
- bazel-bin*/packages_*\r
- bazel-bin*/packages_zip.zip\r
- bazel-bin*/packages_tar.tar.gz\r
+ bazel-bin*/package_*\r
+ bazel-bin*/package_zip.zip\r
+ bazel-bin*/package_tar.tar.gz\r
\r
- name: Publish docker images\r
shell: bash\r
reconnect_delay_growth_factor = 1.25
reconnect_delay_minimum = 5000
reconnect_delay_maximum = 60000
-intents = 32767
\ No newline at end of file
+intents = 32767
while reconnects < self.config.max_reconnects {
info!("Starting connection for shard");
- self._shard_task().await;
+ if let Err(e) = self._shard_task().await {
+ error!("Gateway status: {:?}", e);
+ }
// when the shard got disconnected, the shard task ends
reconnects += 1;
);
}
- async fn _shard_task(&mut self) {
+ async fn _shard_task(&mut self) -> Result<(), GatewayError> {
// create the new connection
let mut connection = Connection::new();
connection.start().await.unwrap();
Some(data) => match data {
Ok(message) => self._handle(&message).await,
Err(error) => {
- error!("An error occured while being connected to Discord: {:?}", error);
- return;
+ return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string()));
},
},
None => {
- info!("Connection terminated");
- return;
+ return Err(GatewayError::from("Connection terminated".to_string()));
},
}
},
_ = timer.tick() => match self._do_heartbeat().await {
Ok(_) => {},
- Err(e) => {
- info!("error occured: {:?}", e);
- return;
+ Err(error) => {
+ return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string()));
},
}
)
Some(data) => match data {
Ok(message) => self._handle(&message).await,
Err(error) => {
- error!("An error occured while being connected to Discord: {:?}", error);
- return;
+ return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string()));
},
},
None => {
- info!("Connection terminated");
- return;
+ return Err(GatewayError::from("Connection terminated".to_string()));
},
}
}