Skip to content

Commit e3d5fc8

Browse files
committed
feat(common): dockerfile, compose and publish action
1 parent 03a4bd4 commit e3d5fc8

File tree

5 files changed

+100
-14
lines changed

5 files changed

+100
-14
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLIENT=rees46

.github/workflows/publish.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- master
9+
paths-ignore:
10+
- .github
11+
workflow_dispatch:
12+
13+
jobs:
14+
docker:
15+
if: |
16+
github.event_name == 'workflow_dispatch' ||
17+
(
18+
github.event.pull_request.merged == true &&
19+
!startsWith(github.head_ref, 'release/')
20+
)
21+
name: Build Docker image and push
22+
uses: rees46/workflow/.github/workflows/docker-publish.yaml@master
23+
permissions: write-all
24+
with:
25+
packageName: api-docs

Dockerfile

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1-
FROM ruby:2.7-slim
1+
FROM ruby:2.7.5-slim AS base
22

3-
WORKDIR /srv/slate
3+
ARG BUNDLE_WITHOUT="test:development"
4+
ENV BUNDLE_WITHOUT="${BUNDLE_WITHOUT}"
45

5-
VOLUME /srv/slate/source
6-
EXPOSE 4567
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
build-essential \
9+
nodejs && \
10+
apt-get autoremove -y && \
11+
rm -rf /var/lib/apt/lists/*
712

8-
COPY . /srv/slate
13+
WORKDIR /app
914

10-
RUN apt-get update \
11-
&& apt-get install -y --no-install-recommends \
12-
build-essential \
13-
nodejs \
14-
&& gem install bundler -v 2.4.22\
15-
&& bundle install \
16-
&& apt-get remove -y build-essential \
17-
&& apt-get autoremove -y \
18-
&& rm -rf /var/lib/apt/lists/*
15+
COPY Gemfile Gemfile.lock ./
16+
17+
RUN BUNDLER_VERSION=$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -1 | tr -d ' ') && \
18+
gem install bundler -v "$BUNDLER_VERSION"
19+
20+
RUN bundle install
21+
22+
COPY . .
1923

2024
CMD ["bundle", "exec", "middleman", "server", "--watcher-force-polling"]
25+
26+
FROM base AS build
27+
28+
ARG BUNDLE_WITHOUT="test:development"
29+
ENV BUNDLE_WITHOUT="${BUNDLE_WITHOUT}"
30+
31+
RUN ./configure.sh r46 && bundle exec middleman build && mv build /opt/rees46
32+
RUN ./configure.sh kameleoon && bundle exec middleman build && mv build /opt/kameleoon
33+
RUN ./configure.sh pc && bundle exec middleman build && mv build /opt/personaclick
34+
35+
FROM nginx:1 AS prod
36+
37+
ENV CLIENT=rees46
38+
39+
COPY --from=build /opt /usr/share/nginx/html
40+
COPY ./config/nginx.conf /etc/nginx/templates/default.conf.template

config/nginx.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
server {
2+
listen 80;
3+
4+
location / {
5+
root /usr/share/nginx/html/${CLIENT};
6+
try_files $uri $uri/ =404;
7+
}
8+
}

docker-compose.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
x-environment: &environment
2+
env_file:
3+
- path: ./.env.example
4+
required: true
5+
- path: ./.env
6+
required: false
7+
8+
networks:
9+
rees46:
10+
name: rees46
11+
driver: bridge
12+
13+
services:
14+
api-docs:
15+
<<: *environment
16+
image: ghcr.io/rees46/api-docs:latest
17+
build:
18+
context: .
19+
target: base
20+
args:
21+
BUNDLE_WITHOUT: ''
22+
ports:
23+
- '${PORT_PUBLIC:-8080}:80'
24+
networks:
25+
- rees46
26+
develop:
27+
watch:
28+
- action: sync
29+
path: .
30+
target: /app
31+
- action: rebuild
32+
path: ./Gemfile.lock

0 commit comments

Comments
 (0)