-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
128 lines (99 loc) · 3.71 KB
/
Dockerfile
File metadata and controls
128 lines (99 loc) · 3.71 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
125
126
127
128
# Setting global arguments
ARG BUNDLE_WITHOUT=development:test
ARG BUNDLE_DEPLOYMENT=true
FROM ruby:3.4-alpine AS build-env
# include global args
ARG BUNDLE_WITHOUT
ARG BUNDLE_DEPLOYMENT
LABEL org.opencontainers.image.authors='pglombardo@hey.com'
# Required packages
RUN apk add --no-cache \
build-base \
curl \
git \
libc6-compat \
libpq-dev \
mariadb-dev \
nodejs \
sqlite-dev \
yaml-dev \
tzdata \
yarn
ENV APP_ROOT=/opt/PasswordPusher
WORKDIR ${APP_ROOT}
ENV PATH=${APP_ROOT}:${PATH} HOME=${APP_ROOT}
COPY Gemfile Gemfile.lock package.json yarn.lock ./
ENV RACK_ENV=production RAILS_ENV=production
RUN bundle config set without "${BUNDLE_WITHOUT}" \
&& bundle config set deployment "${BUNDLE_DEPLOYMENT}" \
&& bundle install
# Removing unneccesary files/directories
RUN rm -rf vendor/bundle/ruby/*/cache \
&& rm -rf vendor/bundle/ruby/*/bundler/gems/*/.git \
&& find vendor/bundle/ruby/*/gems/ -name "*.c" -delete \
&& find vendor/bundle/ruby/*/gems/ -name "*.o" -delete
RUN yarn install
COPY ./ ${APP_ROOT}/
# Normalize line endings for repository scripts only (avoid touching binary gems)
RUN if [ -d ${APP_ROOT}/bin ]; then find ${APP_ROOT}/bin -type f -exec sed -i 's/\r$//' {} \; || true; fi
RUN if [ -d ${APP_ROOT}/script ]; then find ${APP_ROOT}/script -type f -exec sed -i 's/\r$//' {} \; || true; fi
# Also fix shebangs for gem executables installed into vendor/bundle/*/bin
RUN if [ -d ${APP_ROOT}/vendor/bundle/ruby ]; then find ${APP_ROOT}/vendor/bundle/ruby -type f -path '*/bin/*' -exec sed -i 's/\r$//' {} \; || true; fi
# Set DATABASE_URL to sqlite to have a ready
# to use db file for ephemeral configuration
ENV DATABASE_URL=sqlite3:db/db.sqlite3
# Set a default secret_key_base
# For those self-hosting this app, you should
# generate your own secret_key_base and set it
# in your environment.
# 1. Generate a secret_key_base value with:
# bundle exec rails secret
# 2. Set the secret_key_base in your environment:
# SECRET_KEY_BASE=<value>
ENV SECRET_KEY_BASE=783ff1544b9612d8bceb8e26a0bab0cf22543eec658a498e7ef9e1d617976f960092005c8a54cb588759dc6dd8fd054bc4eca4a94dd7b96c6efda4a14a01bfbd
RUN bundle exec bootsnap precompile --gemfile
RUN bundle exec bootsnap precompile app/ lib/
RUN bundle exec rails assets:precompile
RUN bundle exec rake db:setup
################## Build done ##################
FROM ruby:3.4-alpine
# include global args
ARG BUNDLE_WITHOUT
ARG BUNDLE_DEPLOYMENT
LABEL maintainer='pglombardo@hey.com'
# install packages
RUN apk add --no-cache \
bash \
libc6-compat \
libpq \
mariadb-connector-c \
nodejs \
sqlite-dev \
tzdata \
yarn
# Create a user and group to run the application
ARG UID=1000
ARG GID=1000
RUN addgroup -g "${GID}" pwpusher \
&& adduser -D -u "${UID}" -G pwpusher pwpusher
ENV LC_CTYPE=UTF-8 LC_ALL=en_US.UTF-8
ENV APP_ROOT=/opt/PasswordPusher
WORKDIR ${APP_ROOT}
ENV RACK_ENV=production RAILS_ENV=production
# Set a default secret_key_base
# For those self-hosting this app, you should
# generate your own secret_key_base and set it
# in your environment.
# 1. Generate a secret_key_base value with:
# bundle exec rails secret
# 2. Set the secret_key_base in your environment:
# SECRET_KEY_BASE=<value>
ENV SECRET_KEY_BASE=783ff1544b9612d8bceb8e26a0bab0cf22543eec658a498e7ef9e1d617976f960092005c8a54cb588759dc6dd8fd054bc4eca4a94dd7b96c6efda4a14a01bfbd
COPY --from=build-env --chown=pwpusher:pwpusher ${APP_ROOT} ${APP_ROOT}
RUN bundle config set without "${BUNDLE_WITHOUT}" \
&& bundle config set deployment "${BUNDLE_DEPLOYMENT}"
RUN chmod +x /opt/PasswordPusher/entrypoint.sh
RUN sed -i 's/\r$//' entrypoint.sh
ENTRYPOINT ["/opt/PasswordPusher/entrypoint.sh"]
USER pwpusher
EXPOSE 5100