Skip to content

Commit

Permalink
update Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
deviantony committed Oct 13, 2024
1 parent 27c2253 commit 45bdec3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 59 deletions.
81 changes: 39 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ FROM ubuntu:24.04

ARG TARGETOS
ARG TARGETARCH
ARG GO_VERSION=1.22.8
ARG GOLANGCI_LINT_VERSION=v1.61.0
ARG DOCKER_VERSION=27.3.1
ARG DOCKER_COMPOSE_VERSION=2.29.7
ARG NODE_VERSION=18.20.4
ARG YARN_VERSION=1.22.22

EXPOSE 9443
EXPOSE 9000
EXPOSE 8000
EXPOSE 8000 8999 9000 9443

USER root

# Set TERM as noninteractive to suppress debconf errors
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Set default go version
ARG GO_VERSION=go1.22.8.${TARGETOS}-${TARGETARCH}

# Install packages
# Install base packages and utilities
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
dialog \
apt-utils \
Expand All @@ -34,45 +35,41 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

# Install Docker CLI
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& add-apt-repository \
"deb [arch=${TARGETARCH}] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable" \
&& apt-get update \
&& apt-get install -y docker-ce-cli

# Install docker compose plugin
RUN mkdir -p /root/.docker/cli-plugins/ && \
if [ "$TARGETARCH" = "amd64" ]; then \
COMPOSE_ARCH="x86_64"; \
elif [ "$TARGETARCH" = "arm64" ]; then \
COMPOSE_ARCH="aarch64"; \
else \
echo "Unsupported architecture: $TARGETARCH" >&2; \
exit 1; \
fi && \
curl -SL "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-${COMPOSE_ARCH}" -o /root/.docker/cli-plugins/docker-compose && \
chmod +x /root/.docker/cli-plugins/docker-compose

# Install NodeJS
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs

# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update && apt-get -y install yarn
# Install Docker CLI & Docker Compose Plugin
ARG DOCKER_PACKAGE=5:${DOCKER_VERSION}-1~ubuntu.24.04~noble
ARG DOCKER_COMPOSE_PACKAGE=${DOCKER_COMPOSE_VERSION}-1~ubuntu.24.04~noble
RUN install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
chmod a+r /etc/apt/keyrings/docker.asc && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install -y docker-ce-cli=${DOCKER_PACKAGE} docker-compose-plugin=${DOCKER_COMPOSE_PACKAGE}

# Install Golang
ARG GO_PACKAGE=go${GO_VERSION}.${TARGETOS}-${TARGETARCH}
RUN cd /tmp \
&& wget -q https://dl.google.com/go/${GO_VERSION}.tar.gz \
&& tar -xf ${GO_VERSION}.tar.gz \
&& wget -q https://dl.google.com/go/${GO_PACKAGE}.tar.gz \
&& tar -xf ${GO_PACKAGE}.tar.gz \
&& mv go /usr/local

# Install golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /root/go/bin v1.61.0
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /root/go/bin ${GOLANGCI_LINT_VERSION}

# Install NodeJS
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash && \
export NVM_DIR="$HOME/.nvm" && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
nvm install ${NODE_VERSION} && \
nvm use ${NODE_VERSION} && \
nvm alias default ${NODE_VERSION}

# Install Yarn
RUN PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin:${PATH}" npm install --global yarn@${YARN_VERSION}

# Configuring the container with correct PATH and Go configuration
ENV GOROOT="/usr/local/go" \
GOPATH="/root/go" \
PATH="/usr/local/go/bin:/root/go/bin:/root/.nvm/versions/node/v${NODE_VERSION}/bin:${PATH}"

# Configuring Golang
ENV PATH="$PATH:/usr/local/go/bin:/root/go/bin"
22 changes: 5 additions & 17 deletions user-toolkits/alapenna/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
FROM portainer/dev-toolkit:2024.10

# This image uses /root as the home instead of /home/workspace
ENV HOME=/root
# Create a workspace folder
RUN mkdir -pv /workspace && ln -s /workspace /root/workspace

# Prepare a ssh folder placeholder to transfer keys
RUN mkdir -p /root/.ssh

# Prepare a git folder for storing git configuration
RUN mkdir -p /root/.config/git
# Create a workspace folder and link it to /root/workspace
# I also create specific folders for SSH keys and Git configuration
RUN mkdir -p /workspace /root/.ssh /root/.config/git && \
ln -s /workspace /root/workspace

# Install httpie: http://httpie.io/
RUN curl -SsL https://packages.httpie.io/deb/KEY.gpg | apt-key add - \
Expand All @@ -18,14 +12,8 @@ RUN curl -SsL https://packages.httpie.io/deb/KEY.gpg | apt-key add - \

# Install zsh
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.1/zsh-in-docker.sh)"

ENV SHELL=/bin/zsh

# Install docker compose plugin
RUN mkdir -p /root/.docker/cli-plugins/ \
&& curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o /root/.docker/cli-plugins/docker-compose \
&& chmod +x /root/.docker/cli-plugins/docker-compose

# Install air
RUN go install github.com/air-verse/air@latest

Expand All @@ -36,4 +24,4 @@ RUN go install github.com/air-verse/air@latest
RUN printf '[url "ssh://[email protected]/"]\n\tinsteadOf = https://github.com/\n' > /root/.gitconfig

# Update .zshrc
RUN echo 'export PATH="$PATH:/root/.local/bin"' >> /root/.zshrc
RUN echo 'export PATH="$PATH:/root/.local/bin"' >> /root/.zshrc

0 comments on commit 45bdec3

Please sign in to comment.