Skip to content

Commit e9067da

Browse files
committed
dockerfile optimized
1 parent f0364e5 commit e9067da

File tree

15 files changed

+209
-134
lines changed

15 files changed

+209
-134
lines changed

.devcontainer/.dockerignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Ignore a file or directory in the context root named "modules"
2+
modules
3+
4+
# Ignore any files or directories within the subdirectory named "modules"
5+
# in the context root
6+
modules/*
7+
8+
# Ignore any files or directories in the context root beginning with "modules"
9+
modules*
10+
11+
# Ignore any files or directories one level down from the context root named
12+
# "modules"
13+
*/modules
14+
15+
# Ignore any files or directories at any level, including the context root,
16+
# named modules
17+
**/modules
18+
19+
# myProjects
20+
myMTAapp/*
21+
com.myorg.myUI5App/*
22+
myMTA-Project/*
23+
t3e/*
24+
Installation/*
25+
install.txt
26+
testing.txt
27+
test.txt
28+
test-cap-kyma.txt
29+
test-sap-tech-bytes.txt
30+
default-env*
31+
dr-cf-build-sap-overview-page/*
32+
build-sap-overview-page/*
33+
dr-cf-build-sap-overview-page-2/*
34+
cap-media-master/*
35+
dr-cap-media/*
36+
using-UI5-uploadset-with-CAP/*
37+
com.myorg.myUI5App/*
38+
cpapp*

.devcontainer/1-kubectl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# ADD ADDITIONAL FEATURES
4+
# =========================
5+
# KUBECTL
6+
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" \
7+
&& chmod +x ./kubectl \
8+
&& mv ./kubectl /usr/local/bin

.devcontainer/2-kube-devcontainer

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# ADD ADDITIONAL FEATURES
4+
# =========================
5+
# kube-devcontainer
6+
cd /usr/local/share && sudo -s mkdir kube-devcontainer \
7+
&& sudo -s chmod 700 ./kube-devcontainer/ \
8+
&& sudo -s chown --recursive "${USERNAME}":"${USERNAME}" ./kube-devcontainer/

.devcontainer/3-minikube

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# ADD ADDITIONAL FEATURES
4+
# =========================
5+
# MINIKUBE
6+
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
7+
&& chmod +x minikube \
8+
&& sudo -s cp minikube /usr/local/bin && rm minikube

.devcontainer/4-helm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# ADD ADDITIONAL FEATURES
4+
# =========================
5+
# HELM
6+
wget -q https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \
7+
&& chmod +x /usr/local/bin/helm \
8+
&& chmod g+rwx /root \
9+
&& helm repo add "stable" "https://charts.helm.sh/stable" --force-update

.devcontainer/5-docker

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# ADD ADDITIONAL FEATURES
4+
# =========================
5+
# DOCKER
6+
apt-get -y update \
7+
&& apt-get -y install curl \
8+
&& apt-get -y install apt-transport-https \
9+
&& apt-get -y install ca-certificates \
10+
&& apt-get -y install gnupg \
11+
&& apt-get -y install lsb-release \
12+
&& apt-get -y install software-properties-common \
13+
&& rm -rf /var/lib/apt/lists/* \
14+
&& sudo -s groupadd docker \
15+
&& usermod -aG docker "${USERNAME}" \
16+
&& newgrp docker \
17+
&& sudo -u "${USERNAME}" curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
18+
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
19+
&& apt-get -y update \
20+
&& apt-get -y install docker.io

.devcontainer/Dockerfile

100644100755
Lines changed: 41 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,54 @@
55

66
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:16
77

8-
# The javascript-node image includes a non-root node user with sudo access. Use
9-
# the "remoteUser" property in devcontainer.json to use it. On Linux, the container
8+
# The javascript-node image includes a non-root node user with sudo access. Use
9+
# the "remoteUser" property in devcontainer.json to use it. On Linux, the container
1010
# user's GID/UIDs will be updated to match your local UID/GID when using the image
1111
# or dockerFile property. Update USER_UID/USER_GID below if you are using the
1212
# dockerComposeFile property or want the image itself to start with different ID
1313
# values. See https://aka.ms/vscode-remote/containers/non-root-user for details.
1414
ARG USERNAME=node
1515
ARG USER_UID=1000
1616
ARG USER_GID=$USER_UID
17-
# ARG EXTRA_NODE_VERSION=14
1817
ENV KUBECONFIG="/usr/local/share/kube-devcontainer/kubeconfig.yml"
1918
ENV XSCLI="/workspaces/vsc-sap-hana-mta-dev-env-node16x/XS_CLIENT00P_134-70001320"
2019
ENV PATH=$PATH:${XSCLI}/bin
2120
ENV npm config set registry https://registry.npmjs.org/
22-
WORKDIR /usr/app
21+
22+
WORKDIR /workspaces/vsc-sap-hana-mta-dev-env-node16x
2323
COPY ./ ./
24+
# COPY additional-features .
25+
2426
# # # Prepare for apt-based install of Cloud Foundry CLI by adding Cloud Foundry Foundation public key & package repository
2527
# # # (see https://docs.cloudfoundry.org/cf-cli/install-go-cli.html#pkg-linux).
2628
RUN wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - ; \
2729
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list \
2830
&& sudo apt-get -y update \
29-
# To install cf CLI v6, run
30-
&& sudo apt-get -y install cf-cli
31-
32-
# # keytar - Node module to manage system keychain (VSCode keytar)
33-
RUN sudo apt-get update -y && sudo apt-get -y install libsecret-1-dev
34-
35-
# # Alter node user as needed, install tslint, typescript. eslint is installed by javascript image
36-
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
31+
# To install cf CLI v6, run
32+
&& sudo apt-get -y install cf-cli \
33+
# Keytar - Node module to manage system keychain (VSCode keytar)
34+
&& sudo apt-get update -y \
35+
&& sudo apt-get -y install libsecret-1-dev \
36+
# Alter node user as needed, install tslint, typescript. eslint is installed by javascript image
37+
&& if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
3738
groupmod --gid $USER_GID $USERNAME \
3839
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
3940
&& chown -R $USER_UID:$USER_GID /home/$USERNAME; \
4041
fi \
41-
#
42-
# Install tslint, typescript. eslint is installed by javascript image
42+
# Install tslint, typescript. eslint is installed by javascript image
4343
&& sudo -u ${USERNAME} npm install -g typescript \
44-
# https://help.sap.com/viewer/17d50220bcd848aa854c9c182d65b699/Latest/en-US/17efa217f7f34a9eba53d7b209ca4280.html#loio5701672c35354d5b91759a911eaf1171
44+
# https://help.sap.com/viewer/17d50220bcd848aa854c9c182d65b699/Latest/en-US/17efa217f7f34a9eba53d7b209ca4280.html#loio5701672c35354d5b91759a911eaf1171
4545
&& sudo -u ${USERNAME} npm set @sap:registry=https://npm.sap.com -g \
46-
&& sudo -u ${USERNAME} npm update npm -g \
47-
# Install global node modules for SAP CAP and frontend development.
46+
# Install global node modules for SAP CAP and frontend development.
4847
&& npm config set registry https://registry.npmjs.org/ \
49-
# //TODO #1
50-
# https://stackoverflow.com/questions/57534295/npm-err-tracker-idealtree-already-exists-while-creating-the-docker-image-for
51-
# solution added
52-
# WORKDIR /usr/app
53-
# COPY ./ ./
54-
# keytar - Node module to manage system keychain (VSCode keytar)
55-
&& npm i keytar \
48+
# Keytar - Node module to manage system keychain (VSCode keytar)
49+
&& sudo -s npm i keytar \
5650
&& sudo -u ${USERNAME} npm i @sap/cds-dk \
57-
-g mta \
51+
-g mta \
5852
-g mbt \
5953
-g yo \
6054
-g @sap/generator-base-mta-module \
61-
-g @sap/generator-fiori \
55+
-g @sap/generator-fiori \
6256
-g yo generator-easy-ui5 \
6357
-g @ui5/cli \
6458
@sapui5/generator-sapui5-templates \
@@ -67,69 +61,34 @@ RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
6761
@sap/generator-fiori \
6862
@sap/generator-hdb-project \
6963
@sap/hana-client \
70-
hana-cli
71-
72-
# # # Install kubectl (K8s)
73-
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
74-
&& chmod +x ./kubectl \
75-
&& mv ./kubectl /usr/local/bin
76-
77-
# create directory for mounting .kube
78-
RUN cd /usr/local/share && sudo -s mkdir kube-devcontainer \
79-
&& sudo -s chmod 700 ./kube-devcontainer/ \
80-
&& sudo -s chown --recursive ${USERNAME}:${USERNAME} ./kube-devcontainer/
81-
82-
# # # Install extra tools for CAP development & deployment.
83-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
64+
hana-cli \
65+
# Install extra tools for CAP development & deployment.
66+
&& apt-get update && export DEBIAN_FRONTEND=noninteractive \
8467
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
85-
&& apt-get -y install sqlite cf-cli
86-
87-
# Install minikube
88-
RUN curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
89-
&& chmod +x minikube \
90-
&& sudo -s cp minikube /usr/local/bin && rm minikube
91-
92-
# Install Helm
93-
RUN wget -q https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \
94-
&& chmod +x /usr/local/bin/helm \
95-
&& chmod g+rwx /root \
96-
# && mkdir /config \
97-
# && chmod g+rwx /config \
98-
&& helm repo add "stable" "https://charts.helm.sh/stable" --force-update
99-
100-
# Install docker
101-
RUN apt-get -y update \
102-
&& apt-get -y install curl \
103-
&& apt-get -y install apt-transport-https \
104-
&& apt-get -y install ca-certificates \
105-
&& apt-get -y install gnupg \
106-
&& apt-get -y install lsb-release \
107-
&& apt-get -y install software-properties-common \
108-
&& rm -rf /var/lib/apt/lists/*
109-
110-
## Add User node to the docker group
111-
RUN sudo -s groupadd docker \
112-
&& usermod -aG docker ${USERNAME} \
113-
&& newgrp docker
114-
115-
## Install docker
116-
RUN sudo -u ${USERNAME} curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
117-
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
118-
&& apt-get -y update \
119-
&& apt-get -y install docker.io
120-
68+
&& apt-get -y install sqlite cf-cli \
12169
# XS CLI for running against HANA XSA
122-
RUN apt-get update \
70+
&& apt-get update \
12371
&& apt-get install --yes --no-install-recommends procps unzip \
12472
&& rm -rf /var/lib/apt/lists/* \
12573
&& mkdir --parents ${XSCLI} \
126-
&& chown --recursive ${USERNAME}:${USERNAME} ${XSCLI}
127-
74+
&& chown --recursive ${USERNAME}:${USERNAME} ${XSCLI} \
12875
# List all Cloud Foundry CLI plugins to see whether the installation worked.
12976
# cf repo-plugins | grep multiapps
13077
# cf plugins
131-
RUN sudo -u ${USERNAME} cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org \
78+
&& sudo -u ${USERNAME} cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org \
13279
&& sudo -u ${USERNAME} cf install-plugin blue-green-deploy -f -r CF-Community \
13380
&& sudo -u ${USERNAME} cf install-plugin multiapps -f -r CF-Community \
134-
&& sudo -u ${USERNAME} cf install-plugin -f https://github.com/cloudfoundry-incubator/multiapps-cli-plugin/releases/latest/download/multiapps-plugin.linux64
135-
81+
&& sudo -u ${USERNAME} cf install-plugin -f https://github.com/cloudfoundry-incubator/multiapps-cli-plugin/releases/latest/download/multiapps-plugin.linux64 \
82+
# =========================
83+
# ADD ADDITIONAL FEATURES
84+
# =========================
85+
# RUN chmod +x 1-kubectl \
86+
# && ./1-kubectl
87+
# RUN chmod +x 2-kube-devcontainer \
88+
# && ./2-kube-devcontainer
89+
# RUN chmod +x 3-minikube \
90+
# && ./3-minikube
91+
# RUN chmod +x 4-helm \
92+
# && ./4-helm
93+
# RUN chmod +x 5-docker \
94+
# && ./5-docker

.devcontainer/devcontainer.json

100644100755
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@
33
{
44
"name": "VS Code Dev Container for SAP HANA App development (XSA and CF) for Node.js 16.x",
55
"dockerFile": "Dockerfile",
6-
76
// \\wsl$\Ubuntu-20.04\home\user\.kube
87
"mounts": [
98
"source=${env:HOME}${env:USERPROFILE}/.kube,target=/usr/local/share/kube-devcontainer,type=bind"
109
],
11-
1210
// Set *default* container specific settings.json values on container create.
1311
// The default user settings file is located here:
1412
// ==================================================
1513
// Windows %APPDATA%\Code\User\settings.json
1614
"settings": {
1715
"workbench.colorTheme": "codeSTACKr Theme",
1816
"workbench.iconTheme": "vscode-icons",
19-
"editor.formatOnSave": true,
17+
"files.eol": "\n",
2018
"shellformat.flag": "-i=2 -bn -ci -sr"
2119
},
22-
23-
// Add the IDs of extensions you want installed when the container is created.
2420
"extensions": [
2521
"alexcvzz.vscode-sqlite",
2622
"bengreenier.vscode-node-readme",
@@ -64,11 +60,13 @@
6460
"ms-python.python",
6561
"ms-python.vscode-pylance",
6662
"ms-toolsai.jupyter",
67-
"ms-vscode-remote.remote-containers",
68-
"ms-vscode-remote.remote-ssh-edit",
69-
"ms-vscode-remote.remote-ssh",
70-
"ms-vscode-remote.remote-wsl",
71-
"ms-vscode-remote.vscode-remote-extensionpack",
63+
// Activate additional features
64+
// ===============================
65+
// "ms-vscode-remote.remote-containers",
66+
// "ms-vscode-remote.remote-ssh-edit",
67+
// "ms-vscode-remote.remote-ssh",
68+
// "ms-vscode-remote.remote-wsl",
69+
// "ms-vscode-remote.vscode-remote-extensionpack",
7270
"ms-vscode.cpptools",
7371
"ms-vscode.js-debug-nightly",
7472
"ms-vscode.test-adapter-converter",
@@ -102,23 +100,26 @@
102100
"yzhang.markdown-all-in-one",
103101
"foxundermoon.shell-format",
104102
"timonwong.shellcheck",
105-
"github.vscode-pull-request-github",
106103
"saposs.vscode-ui5-language-assistant",
107104
"iljapostnovs.ui5plugin",
108105
"github.vscode-pull-request-github"
109106
],
110-
111107
// Ensure that Docker socket is mapped into the development container
112-
"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"],
113-
// "runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock", "-v", "/usr/local/share/kube-devcontainer://wsl$/Ubuntu-20.04/home/user/.kube/config"],
114-
108+
"runArgs": [
109+
"-v",
110+
"/var/run/docker.sock:/var/run/docker.sock"
111+
],
115112
// Use 'forwardPorts' to make a list of ports inside the container available locally.
116-
"forwardPorts": [3000, 4000, 4004, 5000, 8000, 8080],
117-
113+
"forwardPorts": [
114+
3000,
115+
4000,
116+
4004,
117+
5000,
118+
8000,
119+
8080
120+
],
118121
// Use 'postCreateCommand' to run commands after the container is created.
119-
// "postCreateCommand": "npm install && npm audit fix && npm install --prefix /workspaces/yourAppName/db && --prefix /workspaces/yourAppName/js && npm install --prefix /workspaces/yourAppName/web",
120122
// "postCreateCommand": "npm install && npm audit fix && npm install --prefix /workspaces/yourAppName/db && npm install --prefix /workspaces/yourAppName/js && npm start --prefix /workspaces/yourAppName/js && npm audit fix --prefix /workspaces/yourAppName/js && npm install --prefix /workspaces/yourAppName/web && npm start --prefix /workspaces/yourAppName/db",
121-
122123
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
123124
"remoteUser": "node"
124-
}
125+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cpapp
2121
tutorial
2222
devtoberfest-2021
2323
bookshop
24+
my.db
2425

2526
# docs/.vitepress
2627
# docs/index.md

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88

99
- Nothing yet!
1010

11-
- Changed link
11+
## [1.0.15] - 2021-10-20
12+
13+
- dockerfile optimized
14+
- some features (docker, kubectl, etc.) were outsourced in a separately bash scripts
15+
- added new extensions
1216

1317
## [1.0.9] - 2021-08-31
1418

1519
- Init - Added Everything!
1620

1721
[Unreleased]: https://github.com/draschke/vsc-sap-hana-mta-dev-env-node16x/compare/v1.0.1...HEAD
22+
[1.0.9]: https://github.com/draschke/vsc-sap-hana-mta-dev-env-node16x/compare/v1.0.13...v1.0.15
1823
[1.0.9]: https://github.com/draschke/vsc-sap-hana-mta-dev-env-node16x/compare/v1.0.0...v1.0.9

0 commit comments

Comments
 (0)