Skip to content

Commit 475e75b

Browse files
authored
Move main package to root and add Docker image (#127)
- Move main package to root. - Update golanci-lint configuration. - Build and push Docker container image. - Refine GitHub Actions workflow.
1 parent 8cd93c4 commit 475e75b

File tree

15 files changed

+739
-104
lines changed

15 files changed

+739
-104
lines changed

.devcontainer/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM golang:1.16
2+
3+
# [Option] Install zsh
4+
ARG INSTALL_ZSH="true"
5+
# [Option] Upgrade OS packages to their latest versions
6+
ARG UPGRADE_PACKAGES="false"
7+
# [Option] Enable non-root Docker access in container
8+
ARG ENABLE_NONROOT_DOCKER="true"
9+
# [Option] Use the OSS Moby Engine instead of the licensed Docker Engine
10+
ARG USE_MOBY="true"
11+
12+
# Install needed packages and setup non-root user. Use a separate RUN statement to add your
13+
# own dependencies. A user of "automatic" attempts to reuse an user ID if one already exists.
14+
ARG USERNAME=automatic
15+
ARG USER_UID=1000
16+
ARG USER_GID=$USER_UID
17+
COPY library-scripts/*.sh /tmp/library-scripts/
18+
RUN apt-get update \
19+
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
20+
# Use Docker script from script library to set things up
21+
&& /bin/bash /tmp/library-scripts/docker-in-docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "${USERNAME}" "${USE_MOBY}" \
22+
# Clean up
23+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/
24+
25+
VOLUME [ "/var/lib/docker" ]
26+
27+
# Setting the ENTRYPOINT to docker-init.sh will start up the Docker Engine
28+
# inside the container "overrideCommand": false is set in devcontainer.json.
29+
# The script will also execute CMD if you need to alter startup behaviors.
30+
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
31+
CMD [ "sleep", "infinity" ]
32+
33+
# [Optional] Uncomment this section to install additional OS packages.
34+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
35+
# && apt-get -y install --no-install-recommends <your-package-list-here>

.devcontainer/devcontainer.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or
22
// https://github.com/microsoft/vscode-dev-containers
33
{
4-
"name": "Go",
5-
"image": "golang:1.16",
6-
"runArgs": [
7-
"--cap-add=SYS_PTRACE",
8-
"--security-opt",
9-
"seccomp=unconfined"
10-
],
4+
"name": "Go with Docker in Docker",
5+
"dockerFile": "Dockerfile",
6+
"runArgs": ["--init", "--privileged"],
7+
"overrideCommand": false,
8+
119
// Set *default* container specific settings.json values on container create.
1210
"settings": {
13-
"terminal.integrated.shell.linux": "/bin/bash",
11+
"terminal.integrated.shell.linux": "/bin/zsh",
1412
"go.gopath": "/go"
1513
},
14+
1615
// Add the IDs of extensions you want installed when the container is created.
1716
"extensions": [
18-
"golang.Go"
17+
"golang.Go",
18+
"ms-azuretools.vscode-docker"
1919
],
20+
2021
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2122
// "forwardPorts": [],
23+
2224
// Use 'postCreateCommand' to run commands after the container is created.
2325
"postCreateCommand": "apt-get update && apt-get install -y git && make install"
26+
2427
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
2528
// "remoteUser": "vscode"
2629
}

0 commit comments

Comments
 (0)