forked from MarczalTSIGP/SGTCC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.development
More file actions
124 lines (111 loc) · 4.58 KB
/
Dockerfile.development
File metadata and controls
124 lines (111 loc) · 4.58 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Base Image
FROM ruby:3.4.7
# Encoding
# C.UTF8 locale supports Computer English language
ENV LANG C.UTF-8
# Default user and group id. This is important to avoid permission errors.
#
# All Linux users have a user ID and a group ID and a unique numerical
# identification number called a userid (UID) and a groupid (GID) respectively.
# Groups can be assigned to logically tie users together for a common security,
# privilege and access purpose. It is the foundation of Linux security and
# access.
ARG USER_ID=1000
ARG GROUP_ID=1000
# -q, --quiet
# Quiet. Produces output suitable for logging, omitting progress indicators.
# More q's will produce more quiet up to a maximum of two. You can also use
# -q=# to set the quiet level, overriding the configuration file. Note that
# quiet level 2 implies -y, you should never use -qq without a no-action
# modifier such as -d, --print-uris or -s as APT may decided to do something
# you did not expect.
#
# build-essential is a package which contains references to numerous
# packages needed for building software in general, it contais g++, gcc,
# make tool between others package
#
# curl is used in command lines or scripts to transfer data
#
# libpq-dev are header files and static library for compiling C programs to
# link with the libpq library in order to communicate with a PostgreSQL
# database backend.
#
# libxml2-dev Development files for the GNOME XML library
#
# libxslt1-dev XSLT is an XML language for defining transformations of XML
# files from XML to some other arbitrary format, such as XML, HTML, plain
# text, etc.
#
# imagemagick is a free and open-source software suite for displaying,
# creating, converting, modifying, and editing raster image.
#
# git
# Git is a distributed version-control system for tracking changes in
# source code during software development.
#
# sudo
# sudo is a program for Unix-like computer operating systems that
# allows users to run programs with the security privileges of another user,
# by default the superuser.
#
# ssh
# Secure Shell is a cryptographic network protocol for operating network
# services securely over an unsecured network.
#
# procps
# This package provides command line and full screen utilities for b
# procfs, a "pseudo" file system dynamically generated by the kernel to
# provide information about the status of entries in its process table
# (such as whether the process is running, stopped, or a "zombie").
# .
# It contains free, kill, pkill, pgrep, pmap, ps, pwdx, skill, slabtop,
# snice, sysctl, tload, top, uptime, vmstat, w, and watch.
RUN apt-get update -qq && \
apt-get install -y curl \
libpq-dev \
libxml2-dev \
libxslt1-dev \
imagemagick \
git \
sudo \
ssh \
rsync \
procps \
cron \
vim \
sqlite3
# --------------------------
# INSTALL LAST VERSION OF postgresql-client
# --------------------------
RUN apt-get install -y lsb-release wget ca-certificates gnupg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
apt-get update -qq && \
apt-get install -y postgresql-client
# Define environment variables
ENV _USER rails
ENV APP_NAME sgtcc
ENV APP /var/www/${APP_NAME}
ENV BUNDLE_PATH /bundle/vendor
# Step 1: Create the group with a specific GID
RUN addgroup --gid $GROUP_ID ${_USER}
# Step 2: Create the user with a specific UID and GID, and add to the root group
# --gecos GECOS
# Set the gecos (information about the user) field for the new entry generated. adduser will
# not ask for finger information if this option is given
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID ${_USER} \
&& usermod -a -G root ${_USER} \
&& usermod -a -G staff ${_USER}
# Step 3: Ensure the user can run all commands as root (no sudo pwd required)
RUN echo "${_USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN mkdir -p $APP \
&& mkdir -p $BUNDLE_PATH
RUN chown -R ${_USER}:${_USER} /bundle $APP
## Change current user
USER ${_USER}:${_USER}
# Set working directory
WORKDIR $APP
# Install bundler and rails
RUN gem install bundler -v 2.7.2 \
&& gem install rails -v 8.1.1