удалить лишнее
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -1,36 +1,25 @@
|
||||
FROM ubuntu:24.04 AS ubuntu
|
||||
|
||||
# setting non-interactive mode for apt
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# update system and install the required stuff
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
RUN apt-get install -y --no-install-recommends \
|
||||
gosu
|
||||
|
||||
# install packages appearing in packages.list
|
||||
# clean up chache and remove package lists
|
||||
COPY ./packages.list /tmp
|
||||
RUN xargs apt-get install -y --no-install-recommends </tmp/packages.list && \
|
||||
apt-get clean && \
|
||||
rm /tmp/packages.list
|
||||
|
||||
|
||||
# install what can not be installed with
|
||||
# package manager
|
||||
COPY ./build_time_scripts.sh /tmp
|
||||
COPY ./custom /tmp/custom
|
||||
RUN /tmp/build_time_scripts.sh /tmp/custom && \
|
||||
rm -rf /tmp/build_time_scripts.sh /tmp/custom
|
||||
|
||||
|
||||
# set working dir inside the container
|
||||
WORKDIR /home/ubuntu
|
||||
|
||||
# password to log in as ubuntu user
|
||||
ENV SECRET="ubuntu"
|
||||
|
||||
# copy enrypoint script
|
||||
COPY ./entrypoint.sh /usr/bin/entrypoint-docker.sh
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "/usr/bin/entrypoint-docker.sh"]
|
||||
|
||||
3
Makefile
3
Makefile
@@ -1,6 +1,5 @@
|
||||
#image basename
|
||||
BASENAME=devenv
|
||||
# TODO use git tag
|
||||
|
||||
IMAGE_NAME=$(BASENAME):latest
|
||||
|
||||
build:
|
||||
|
||||
62
README.md
62
README.md
@@ -1,58 +1,6 @@
|
||||
# devenv
|
||||
**devenv** is a tool to quickly build a Docker image based on Ubuntu 22.04 with
|
||||
easily customisable set of packages. The image is built with an entrypoint script
|
||||
which lets you set up an unprivileged user in container OS.
|
||||
# Репозиторий для проведения интервью
|
||||
Ваши задачи:
|
||||
|
||||
The whole story is intended for developers needing to experiment with different
|
||||
versions of build tools etc.
|
||||
|
||||
## Customise
|
||||
1. Customize packages that you want to install into the
|
||||
container OS. Just edit the **packages.list** putting
|
||||
one package name per line.
|
||||
|
||||
2. Add shell scripts or binaries to **./custom** directory. These
|
||||
will run at build time as **root** and the produced result will be
|
||||
baked into the image.
|
||||
|
||||
3. **(optional)** edit Makefile, Dockerfile, entrypoint.sh accoriding
|
||||
to your requirements.
|
||||
|
||||
## Build the image
|
||||
This builds Docker image with Ubuntu 22.04 as base
|
||||
installing the tools you chose above. Note that build
|
||||
executes all scripts in **./scripts** directory if any are present.
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
## Entrypoint
|
||||
Entrypoint script creates an unprivileged user in container system.
|
||||
Username, gid and uig can be altered when launching the container by passing environment
|
||||
variables to docker run.
|
||||
|
||||
If no environment variables were passed to docker run, the unprivileged user will
|
||||
default to **developer:developer** with uig/gid **1001:1001**.
|
||||
|
||||
By default the unprivileged user created by entrpoint script has passwordless sudo.
|
||||
If this is not the desired behaviour - consider editing **entrypoint.sh** before
|
||||
building the image.
|
||||
|
||||
## Create launch script
|
||||
This will create a bash script that runs the Docker container from the image
|
||||
built above with your current username, uid and gid. Since username, uid and
|
||||
gid are the same as in your host system you can safely mount anything from
|
||||
your host system into container without creating mess in host OS.
|
||||
|
||||
By default the launch script mounts your home directory into the unprivileged
|
||||
user's home in the container. Edit the produced script as approprite if this
|
||||
is not the desired behaviour.
|
||||
```bash
|
||||
make script
|
||||
```
|
||||
|
||||
## Create and install launch script
|
||||
This will create the launch script (see above) and place it into you
|
||||
**$HOME/.local/bin** creating the directory is if does not exist.
|
||||
```bash
|
||||
make install
|
||||
```
|
||||
1. Прочитать и прокомментрировать код в файлах: что делает, что можно улучшить.
|
||||
2. Получить у собеседующего адрес для подключения и пароль пользоваталя **ubuntu**.
|
||||
3. Подключиться к удаленной машине по ssh и выполнять указания интервьюера.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# exit on errors
|
||||
set -e
|
||||
# now let's fire up all the scripts from the
|
||||
# directory which we received as a second argument
|
||||
|
||||
if [ "$(ls $1)" ]; then
|
||||
for script in $1/*
|
||||
do
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# install vanilla Go 1.24.3
|
||||
set -e
|
||||
echo "fetching go compiler"
|
||||
|
||||
curl --location https://go.dev/dl/go1.24.3.linux-amd64.tar.gz -o /tmp/go.tar.gz
|
||||
echo "unpacking go compiler..."
|
||||
tar -xzf /tmp/go.tar.gz -C /usr/local
|
||||
echo "removing archive"
|
||||
rm /tmp/go.tar.gz
|
||||
ln -s /usr/local/go/bin/* /usr/bin
|
||||
echo "Go 1.24.3 installed into /usr/local"
|
||||
|
||||
echo "Go compiler installed"
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
set -e
|
||||
|
||||
# set password
|
||||
echo "ubuntu:${SECRET}" | chpasswd
|
||||
|
||||
usermod -aG sudo ubuntu
|
||||
|
||||
mkdir /run/sshd
|
||||
/sbin/sshd -o "PasswordAuthentication=yes"
|
||||
|
||||
# add ubuntu to groups
|
||||
usermod -aG sudo ubuntu
|
||||
|
||||
exec gosu ubuntu:ubuntu $@
|
||||
|
||||
Reference in New Issue
Block a user