This repository was archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
85 lines (69 loc) · 2.35 KB
/
Dockerfile
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
### === base === ###
FROM ruby:3.1.2-alpine AS base
RUN apk add --no-cache --update postgresql-dev tzdata nodejs
RUN adduser -D develop
RUN gem install bundler
# ENV PYTHON=/usr/bin/python3
### === development === ###
FROM base AS development
RUN apk add --update build-base \
libffi \
python3 \
linux-headers \
git \
yarn \
gcompat \
less \
curl \
gnupg \
openssh-client
RUN gem install solargraph standardrb ruby-debug-ide debug rufo
ENV BUNDLE_CACHE_ALL=true
ENV BUNDLE_PATH=/home/develop/app/vendor/bundle
USER develop
RUN mkdir -p /home/develop/app
WORKDIR /home/develop/app
### === build === ###
FROM development AS build
ENV RAILS_ENV=production
COPY --chown=develop . /home/develop/app
RUN mkdir -p /home/develop/app/vendor/cache && \
mkdir -p /home/develop/app/vendor/bundle && \
mkdir -p /home/develop/app/node_modules
RUN bundle install && \
bundle clean && \
bundle package
RUN yarn install && \
NODE_ENV=production bin/webpacker
### === production === ###
FROM base AS production
# Install OpenSSH and set the password for root to "Docker!". In this example, "apk add" is the install instruction for an Alpine Linux-based image.
# See here for details: https://docs.microsoft.com/en-us/azure/app-service/configure-linux-open-ssh-session#use-ssh-support-with-custom-docker-images
RUN apk add --no-cache openssh su-exec \
&& echo "root:Docker!" | chpasswd
# Copy the sshd_config file to the /etc/ssh/ directory
COPY .docker/sshd_config /etc/ssh/
COPY .docker/entrypoints/azure-entrypoint.sh /azure-entrypoint
COPY .docker/entrypoints/entrypoint.sh /entrypoint
# Copy and configure the ssh_setup file
RUN mkdir -p /tmp
COPY .docker/ssh_setup.sh /tmp
RUN chmod +x /tmp/ssh_setup.sh \
&& (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null)
RUN adduser -D app && mkdir -p /app && chown -R app /app
USER app
WORKDIR /app
ENV BUNDLE_WITHOUT="test:development"
ENV BUNDLE_DEPLOYMENT="true"
ENV BUNDLE_PATH=/app/vendor/bundle
ENV RAILS_ENV=production
ENV NODE_ENV=production
ENV RAILS_LOG_TO_STDOUT="true"
ENV PORT=3000
COPY --chown=app --from=build /home/develop/app /app
RUN bundle install --local
RUN rm -rf /app/node_modules/*
USER root
EXPOSE $PORT 2222
ENTRYPOINT ["/azure-entrypoint"]
CMD ["bin/rails", "s", "-b", "0.0.0.0"]