Browse Source

Added initial devcontainer support.

pull/709/head
Alex Laurie 5 months ago
parent
commit
34b350599a
  1. 49
      .devcontainer/Dockerfile
  2. 25
      .devcontainer/devcontainer.json

49
.devcontainer/Dockerfile

@ -0,0 +1,49 @@
# Use AlmaLinux as the base image
FROM almalinux:latest
# Update and install necessary packages
RUN dnf update -y && \
dnf install -y \
git \
python3 \
wget \
tar \
shadow-utils \
sudo \
&& dnf clean all
# Set up arguments for Hugo installation
ARG HUGO_VERSION=latest
ARG HUGO_VARIANT=hugo_extended
# Download and install Hugo
RUN if [ "$HUGO_VERSION" = "latest" ]; then \
HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}'); \
fi && \
echo "Installing Hugo version: ${HUGO_VERSION}" && \
wget -O hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_VARIANT}_${HUGO_VERSION}_Linux-64bit.tar.gz && \
tar -xzf hugo.tar.gz && \
mv hugo /usr/local/bin/hugo && \
chmod +x /usr/local/bin/hugo && \
rm hugo.tar.gz
# Create a non-root user for development
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
USER vscode
# Expose port for Hugo server
EXPOSE 1313
# Set the working directory
WORKDIR /workspace
# Set the default command to run Hugo server
CMD ["hugo", "server", "--bind=0.0.0.0"]

25
.devcontainer/devcontainer.json

@ -0,0 +1,25 @@
{
"name": "AlmaLinux_WWW_Container",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "hugo",
"VERSION": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
"budparr.language-hugo-vscode",
"ms-python.python",
"esbenp.prettier-vscode",
"yzhang.markdown-all-in-one",
"tamasfe.even-better-toml"
]
},
"terminal.integrated.shell.linux": "/bin/bash"
},
"forwardPorts": [1313],
"remoteUser": "vscode"
}
Loading…
Cancel
Save