-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
97 lines (77 loc) · 2.75 KB
/
Dockerfile
File metadata and controls
97 lines (77 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
ARG NODE_VERSION=22.14
FROM node:${NODE_VERSION}
# Set the SHELL environment variable to your shell name
ENV SHELL=/bin/bash
# Install system packages needed for Bit development server
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
jq \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libatspi2.0-0 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libnspr4 \
libnss3 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxkbcommon0 \
libxrandr2 \
libcups2 \
zstd \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create a new user "bituser" and switch to it
RUN useradd -m bituser
# Modify permissions for /usr/local/bin to allow symlink creation by non-root users
RUN chmod a+w /usr/local/bin
# Install and prepare Corepack for managing pnpm
RUN corepack enable
RUN corepack prepare pnpm@latest-9 --activate
# Switch to user "bituser"
USER bituser
# Create the workspace directory within the user's home directory
RUN mkdir -p /home/bituser/workspace
# Set the working directory to the user's workspace
WORKDIR /home/bituser/workspace
# Create a directory for global installations
RUN mkdir /home/bituser/.npm-global
RUN mkdir -p /home/bituser/.npm-global/lib
# Configure npm to use the new directory path and ensure global binaries are accessible
ENV PATH=/home/bituser/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/bituser/.npm-global
# Install BVM and Bit
RUN npm install -g @teambit/bvm \
&& npm cache clean --force
# Set release type to nightly based on NIGHTLY argument
ARG NIGHTLY=false
RUN if [ "$NIGHTLY" = "true" ] ; then bvm config set RELEASE_TYPE nightly ; fi
RUN bvm upgrade
ENV PATH=$PATH:/home/bituser/bin
# Set the NODE_OPTIONS environment variable to increase the heap size
ARG NODE_HEAP_SIZE=4096
LABEL node.heap.size=${NODE_HEAP_SIZE}
ENV NODE_OPTIONS="--max-old-space-size=${NODE_HEAP_SIZE}"
# Set the correct registry
RUN npm config set '@bit:registry' https://node-registry.bit.cloud
RUN npm config set '@teambit:registry' https://node-registry.bit.cloud
# Set the default bit configurations for docker
ENV BIT_CONFIG_ANALYTICS_REPORTING="false"
ENV BIT_CONFIG_INTERACTIVE="false"
ENV BIT_DISABLE_CONSOLE="true"
# Copy scripts and ensure permissions
USER root
COPY scripts /home/bituser/scripts
RUN chown -R bituser:bituser /home/bituser/scripts
RUN chmod +x /home/bituser/scripts/*
ENV PATH=$PATH:/home/bituser/scripts
# Ensure bituser has permission to create directories and symlinks
RUN mkdir -p /__w /home \
&& chown -R bituser:bituser /home /__w \
&& chmod -R 775 /home /__w
# Switch back to bituser for running commands
USER bituser
# Set the default command to start a shell
CMD ["/bin/bash"]