Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88f74dc

Browse files
-
1 parent 0ae30f5 commit 88f74dc

File tree

2 files changed

+162
-162
lines changed

2 files changed

+162
-162
lines changed

.devcontainer/Dockerfile

Lines changed: 139 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,139 @@
1-
# -------------------------------------------------------------------------------------------------
2-
FROM ubuntu:latest as builder
3-
4-
LABEL MAINTAINER="Ralph Göstenmeier"
5-
6-
ARG DEBIAN_FRONTEND=noninteractive
7-
8-
ARG USR_NAME=user
9-
ARG USR_HOME=/home/${USR_NAME}
10-
ARG USR_ID=10000
11-
12-
ARG GRP_NAME=work
13-
ARG GRP_ID=10000
14-
15-
# set environment variables
16-
ENV TZ 'Europe/Berlin'
17-
RUN echo $TZ > /etc/timezone
18-
19-
# -------------------------------------------------------------------------------------------------
20-
# BASE
21-
# -------------------------------------------------------------------------------------------------
22-
FROM builder as base
23-
24-
RUN apt-get update
25-
RUN apt install --yes tzdata \
26-
&& rm /etc/localtime \
27-
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
28-
&& dpkg-reconfigure -f noninteractive tzdata \
29-
&& apt-get clean
30-
31-
RUN apt install --yes build-essential lsb-release curl sudo git vim unzip
32-
RUN apt install --yes software-properties-common
33-
34-
# -------------------------------------------------------------------------------------------------
35-
# WITH-USER
36-
# -------------------------------------------------------------------------------------------------
37-
FROM base as with-user
38-
39-
RUN groupadd ${GRP_NAME} --gid ${GRP_ID}
40-
RUN adduser ${USR_NAME} --uid ${USR_ID} --gid ${GRP_ID} --home ${USR_HOME} --disabled-password --gecos User
41-
42-
RUN mkdir -p ${USR_HOME}/bin
43-
RUN chown -R ${USR_NAME}:${GRP_NAME} ${USR_HOME}/bin
44-
45-
RUN echo '%work ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/${GRP_NAME}
46-
47-
# -------------------------------------------------------------------------------------------------
48-
# PYTHON
49-
# -------------------------------------------------------------------------------------------------
50-
FROM with-user as with-python
51-
52-
RUN apt install --yes python3 python3-pip python3-venv
53-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
54-
55-
ENV PYTHONDONTWRITEBYTECODE 1
56-
ENV PYTHONUNBUFFERED 1
57-
58-
# -------------------------------------------------------------------------------------------------
59-
# NODEJS
60-
# -------------------------------------------------------------------------------------------------
61-
FROM with-python as with-nodejs
62-
63-
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
64-
RUN apt install -y nodejs
65-
RUN npm install -g ijavascript
66-
67-
RUN echo 'export PATH="$HOME/bin:$PATH:/coding4beginner/bin\n"' >>${USR_HOME}/.bashrc
68-
69-
# -------------------------------------------------------------------------------------------------
70-
# DOTNET
71-
# -------------------------------------------------------------------------------------------------
72-
FROM with-nodejs as with-dotnet
73-
74-
RUN apt-get update \
75-
&& apt install --yes dotnet-sdk-8.0
76-
77-
78-
# -------------------------------------------------------------------------------------------------
79-
# PHP
80-
# -------------------------------------------------------------------------------------------------
81-
FROM with-dotnet as with-php
82-
83-
RUN apt-get update \
84-
&& apt install --yes php libapache2-mod-php
85-
86-
# -------------------------------------------------------------------------------------------------
87-
# DJANGO
88-
EXPOSE 8000
89-
90-
# -------------------------------------------------------------------------------------------------
91-
FROM with-php as with-apps
92-
93-
# =================================================================================================
94-
# USER
95-
# =================================================================================================
96-
FROM with-apps as final
97-
98-
USER user
99-
100-
VOLUME [ "/coding4beginner" ]
101-
WORKDIR /coding4beginner
102-
103-
# -------------------------------------------------------------------------------------------------
104-
# PYTHON
105-
RUN python -m venv ${USR_HOME}/.venv
106-
RUN echo '\n\n. /home/user/.venv/bin/activate\n' >>${USR_HOME}/.bashrc
107-
COPY requirements.txt requirements.txt
108-
RUN ${USR_HOME}/.venv/bin/pip install -r requirements.txt
109-
110-
# -------------------------------------------------------------------------------------------------
111-
# DENO
112-
RUN curl -fsSL https://deno.land/install.sh | sh
113-
RUN echo '\n\n# Deno\nexport DENO_INSTALL="/home/user/.deno"\n' >>${USR_HOME}/.bashrc
114-
RUN echo 'export PATH="$DENO_INSTALL/bin:$PATH"\n' >>${USR_HOME}/.bashrc
115-
116-
# -------------------------------------------------------------------------------------------------
117-
# JUPYTER
118-
RUN sudo npm install ijavascript
119-
RUN PATH=${USR_HOME}/.venv/bin:$PATH: ijsinstall --install=local
120-
RUN PATH=${USR_HOME}/.venv/bin:${USR_HOME}/.deno/bin:$PATH: deno jupyter --install
121-
122-
# -------------------------------------------------------------------------------------------------
123-
# VSCODE
124-
RUN mkdir -p /coding4beginner/.vscode
125-
COPY vscode/* /coding4beginner/.vscode
126-
COPY bin/* /coding4beginner/bin
127-
128-
RUN sudo mkdir -p ${USR_HOME}/bin
129-
RUN sudo chown -R ${USR_NAME}:${GRP_NAME} ${USR_HOME}/bin /coding4beginner
130-
RUN sudo chmod -R +x ${USR_HOME}/bin
131-
132-
# -------------------------------------------------------------------------------------------------
133-
# CLEANUP
134-
# -------------------------------------------------------------------------------------------------
135-
RUN sudo apt update \
136-
&& sudo apt upgrade --yes
137-
138-
139-
CMD ["bash", "-l"]
1+
# -------------------------------------------------------------------------------------------------
2+
FROM ubuntu:latest as builder
3+
4+
LABEL MAINTAINER="Ralph Göstenmeier"
5+
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
8+
ARG USR_NAME=user
9+
ARG USR_HOME=/home/${USR_NAME}
10+
ARG USR_ID=10000
11+
12+
ARG GRP_NAME=work
13+
ARG GRP_ID=10000
14+
15+
# set environment variables
16+
ENV TZ 'Europe/Berlin'
17+
RUN echo $TZ > /etc/timezone
18+
19+
# -------------------------------------------------------------------------------------------------
20+
# BASE
21+
# -------------------------------------------------------------------------------------------------
22+
FROM builder as base
23+
24+
RUN apt-get update
25+
RUN apt install --yes tzdata \
26+
&& rm /etc/localtime \
27+
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
28+
&& dpkg-reconfigure -f noninteractive tzdata \
29+
&& apt-get clean
30+
31+
RUN apt install --yes build-essential lsb-release curl sudo git vim unzip
32+
RUN apt install --yes software-properties-common
33+
34+
# -------------------------------------------------------------------------------------------------
35+
# WITH-USER
36+
# -------------------------------------------------------------------------------------------------
37+
FROM base as with-user
38+
39+
RUN groupadd ${GRP_NAME} --gid ${GRP_ID}
40+
RUN adduser ${USR_NAME} --uid ${USR_ID} --gid ${GRP_ID} --home ${USR_HOME} --disabled-password --gecos User
41+
42+
RUN mkdir -p ${USR_HOME}/bin
43+
RUN chown -R ${USR_NAME}:${GRP_NAME} ${USR_HOME}/bin
44+
45+
RUN echo '%work ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/${GRP_NAME}
46+
47+
# -------------------------------------------------------------------------------------------------
48+
# PYTHON
49+
# -------------------------------------------------------------------------------------------------
50+
FROM with-user as with-python
51+
52+
RUN apt install --yes python3 python3-pip python3-venv
53+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
54+
55+
ENV PYTHONDONTWRITEBYTECODE 1
56+
ENV PYTHONUNBUFFERED 1
57+
58+
# -------------------------------------------------------------------------------------------------
59+
# NODEJS
60+
# -------------------------------------------------------------------------------------------------
61+
FROM with-python as with-nodejs
62+
63+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
64+
RUN apt install -y nodejs
65+
RUN npm install -g ijavascript
66+
67+
RUN echo 'export PATH="$HOME/bin:$PATH:/c4b/bin\n"' >>${USR_HOME}/.bashrc
68+
69+
# -------------------------------------------------------------------------------------------------
70+
# DOTNET
71+
# -------------------------------------------------------------------------------------------------
72+
FROM with-nodejs as with-dotnet
73+
74+
RUN apt-get update \
75+
&& apt install --yes dotnet-sdk-8.0
76+
77+
78+
# -------------------------------------------------------------------------------------------------
79+
# PHP
80+
# -------------------------------------------------------------------------------------------------
81+
FROM with-dotnet as with-php
82+
83+
RUN apt-get update \
84+
&& apt install --yes php libapache2-mod-php
85+
86+
# -------------------------------------------------------------------------------------------------
87+
# DJANGO
88+
EXPOSE 8000
89+
90+
# -------------------------------------------------------------------------------------------------
91+
FROM with-php as with-apps
92+
93+
# =================================================================================================
94+
# USER
95+
# =================================================================================================
96+
FROM with-apps as final
97+
98+
USER user
99+
100+
VOLUME [ "/c4b" ]
101+
WORKDIR /c4b
102+
103+
# -------------------------------------------------------------------------------------------------
104+
# PYTHON
105+
RUN python -m venv ${USR_HOME}/.venv
106+
RUN echo '\n\n. /home/user/.venv/bin/activate\n' >>${USR_HOME}/.bashrc
107+
COPY requirements.txt requirements.txt
108+
RUN ${USR_HOME}/.venv/bin/pip install -r requirements.txt
109+
110+
# -------------------------------------------------------------------------------------------------
111+
# DENO
112+
RUN curl -fsSL https://deno.land/install.sh | sh
113+
RUN echo '\n\n# Deno\nexport DENO_INSTALL="/home/user/.deno"\n' >>${USR_HOME}/.bashrc
114+
RUN echo 'export PATH="$DENO_INSTALL/bin:$PATH"\n' >>${USR_HOME}/.bashrc
115+
116+
# -------------------------------------------------------------------------------------------------
117+
# JUPYTER
118+
RUN sudo npm install ijavascript
119+
RUN PATH=${USR_HOME}/.venv/bin:$PATH: ijsinstall --install=local
120+
RUN PATH=${USR_HOME}/.venv/bin:${USR_HOME}/.deno/bin:$PATH: deno jupyter --install
121+
122+
# -------------------------------------------------------------------------------------------------
123+
# VSCODE
124+
RUN mkdir -p /c4b/.vscode
125+
COPY vscode/* /c4b/.vscode
126+
COPY bin/* /c4b/bin
127+
128+
RUN sudo mkdir -p ${USR_HOME}/bin
129+
RUN sudo chown -R ${USR_NAME}:${GRP_NAME} ${USR_HOME}/bin /c4b
130+
RUN sudo chmod -R +x ${USR_HOME}/bin
131+
132+
# -------------------------------------------------------------------------------------------------
133+
# CLEANUP
134+
# -------------------------------------------------------------------------------------------------
135+
RUN sudo apt update \
136+
&& sudo apt upgrade --yes
137+
138+
139+
CMD ["bash", "-l"]

.devcontainer/docker-compose.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
version: "3.8"
2-
3-
services:
4-
app:
5-
build:
6-
context: .
7-
dockerfile: Dockerfile
8-
9-
container_name: coding4beginner
10-
volumes:
11-
- ../../Lessons:/coding4beginner/lessons
12-
- ../../Workspace:/coding4beginner/workspace
13-
- ../../Courses:/coding4beginner/courses
14-
15-
- ../..:/ROOT
16-
ports:
17-
- 8000:8000
18-
- 8008:8080
19-
20-
environment:
21-
- DJANGO_DEBUG=1
22-
23-
command: /bin/sh -c "while sleep 1000; do :; done"
1+
version: "3.8"
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
9+
container_name: coding4beginner
10+
volumes:
11+
- ../../Lessons:/c4b/lessons
12+
- ../../Workspace:/c4b/workspace
13+
- ../../Courses:/c4b/courses
14+
15+
- ../..:/ROOT
16+
ports:
17+
- 8000:8000
18+
- 8008:8080
19+
20+
environment:
21+
- DJANGO_DEBUG=1
22+
23+
command: /bin/sh -c "while sleep 1000; do :; done"

0 commit comments

Comments
 (0)