Skip to content

Commit d1eb5f5

Browse files
committed
Switch to docker compose for dev & prod
That commit is allowing easier contribution by using docker container to develop and release the application. A Makefile is providing the basic wrapper to start the container.
1 parent 835d508 commit d1eb5f5

File tree

91 files changed

+250
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+250
-237
lines changed

.docker/config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ~/.docker/config.json
2+
{
3+
"features": {
4+
"buildkit": true
5+
}
6+
}

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# .dockerignore
2+
3+
.git
4+
.gitignore
5+
README.md
6+
bin/
7+
blib/
8+
deploy/
9+
launcher/
10+
lib/
11+
local/
12+
public/
13+
t/
14+
tools/
15+
var/
16+
views/
17+
.env
18+
*.log
19+
*.swp

ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
---
2+
name: 🐛 Bug report
3+
about: Report a problem with the app
4+
title: "[BUG]"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
110
## Context
211

312
[provide more detailed introduction to the issue itself and why it is relevant]

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: 💬 Community Support
4+
url: //github.com/metacpan/metacpan-grep-front-end/discussions/
5+
about: Please use GitHub Discussions for questions and support.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.DS_Store
2+
.env
23
.tidyall.d
34
MYMETA.json
45
MYMETA.yml
5-
Makefile
66
blib
77
local
88
pm_to_blib

.travis.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

Dockerfile

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,51 @@
1-
FROM metacpan/metacpan-base:latest
1+
##
2+
## Temporary image for installing metacpan packages
3+
##
4+
5+
FROM metacpan/metacpan-base:latest AS builder
6+
SHELL [ "/bin/bash", "-eo", "pipefail", "-c" ]
7+
8+
WORKDIR /metacpan-grep-front-end
9+
10+
COPY cpanfile ./
11+
COPY cpanfile.snapshot ./
12+
13+
RUN <<EOT
14+
cpm install -g \
15+
--without-test \
16+
--with-recommends \
17+
--with-develop \
18+
--cpanfile cpanfile
19+
EOT
20+
21+
##
22+
## Runtime image for metacpan-grep-front-end
23+
##
24+
25+
FROM builder AS runtime
26+
SHELL [ "/bin/bash", "-eo", "pipefail", "-c" ]
227

3-
ADD . /metacpan-grep-front-end
428
WORKDIR /metacpan-grep-front-end
529

6-
RUN cpm install --without-test -g
30+
# Build arguments
31+
ARG APP_ENV=development
32+
33+
# Runtime
34+
ENV APP_ENV=$APP_ENV
35+
36+
# FIXME
37+
#ADD . /metacpan-grep-front-end
38+
COPY src/ ./
39+
RUN ls -la
40+
41+
# always expose a consistent port
742
EXPOSE 3000
43+
# volume controlled by the docker-compose.yml
844
VOLUME [ "/metacpan-cpan-extracted" ]
9-
CMD plackup -p 3000 ${GREP_PLACKUP_SERVER_ARGS} bin/app.psgi
45+
46+
# Make the entrypoint script executable
47+
COPY docker-entrypoint.sh ./
48+
RUN chmod +x docker-entrypoint.sh
49+
50+
# Use the dynamic entrypoint
51+
ENTRYPOINT ["./docker-entrypoint.sh"]

MANIFEST

Lines changed: 0 additions & 24 deletions
This file was deleted.

MANIFEST.SKIP

Lines changed: 0 additions & 17 deletions
This file was deleted.

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
.PHONY: all up-dev up-prod up
3+
4+
APP_ENV ?= development
5+
6+
all:
7+
$(MAKE) up
8+
9+
up:
10+
ln -sf config/docker-compose.$(APP_ENV).env .env
11+
APP_ENV=$(APP_ENV) docker compose up --build
12+
13+
up-dev:
14+
$(MAKE) up APP_ENV=development
15+
16+
up-prod:
17+
$(MAKE) up APP_ENV=production

Makefile.PL

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,8 @@ but it should be pretty straight forward to setup a development environment and
1414

1515
## Requirements
1616

17-
* a git client (should be compiled with libpcre)
18-
* perl 5.36 or later (5.36 is the recommended version, consider [using perlbrew](https://perlbrew.pl))
19-
* App::cpanminus (read manual on [metacpan](https://metacpan.org/pod/App::cpanminus) )
20-
21-
### git with pcre support
22-
23-
For macOS users, it's recommended to use [homebrew](https://brew.sh) to install git with pcre support
24-
25-
> brew install pcre
26-
> export USE_LIBPCRE=yes
27-
> brew reinstall --build-from-source git
28-
29-
You can check if git support pcre by using the '-P' option
30-
31-
# example:
32-
> git grep -c -P "\w"
17+
* docker & docker compose
18+
* checkout a version of `metacpan-extracted` view details after to use `metacpan-cpan-extracted-lite`
3319

3420
## Cloning repositories
3521

@@ -56,39 +42,13 @@ It should be clone at the same level of *metacpan-grep-front-end* itself (do not
5642
> ls -d metacpan-*
5743
metacpan-cpan-extracted-lite metacpan-grep-front-end
5844

59-
## Installing dependencies
60-
61-
Now that you have the repository set, let's install all the perl modules required.
62-
63-
You can check your perl version. ( 5.036000 is the recommended one for now )
64-
65-
perl -E 'say $]'
66-
67-
All modules are listed in the `cpanfile` file itself.
68-
Running `install.sh` itself should do all the magic
69-
( which does more than only installing the perl modules )
70-
71-
./install.sh
72-
73-
But if you prefer you can simply run manually:
74-
75-
> cpanm --installdeps --with-develop --with-recommends .
76-
7745
## Starting the development server
7846

79-
Once you have installed all perl modules, you should be able to start
80-
the plack server by simply running:
81-
82-
> ./devel-server
47+
> make # alias to `make up` or `make up-dev`
8348
Watching . bin/lib bin/app.psgi for file updates.
8449
HTTP::Server::PSGI: Accepting connections at http://0:5010/
8550

86-
This would use plack to run the psgi app and listen by default on port 5010.
87-
Any change to any of the file, should automatically trigger a plack restart.
88-
89-
You should let that plack server run in a dedicated terminal then use another
90-
terminal for your own development.
91-
Note: errors would be logged in the 'devel-server' terminal.
51+
This will start a docker container setup by `docker-compose.yml` using by default the `development` environment.
9252

9353
You can now open your browser to this url, and you should be able to see the
9454
grep.metacpan.org homepage.
@@ -116,12 +76,3 @@ From there you should be ready to
11676
-> Submit a Pull Request to GitHub
11777
# continue to hack, hack, ...
11878
have fun !
119-
120-
## Travis CI
121-
122-
The project comes with a basic `.travis.yml` file.
123-
124-
If you want to start smoking your own branches, you simply need to link your [GitHub account](https://github.com/)
125-
to your [Travis CI account](https://travis-ci.org/), then enable the repository in your [Travis Dashboard](https://travis-ci.org/dashboard)
126-
127-
Note that any Pull Request submitted via GitHub would trigger a Travis smoke without any settings required from your side :-)

app.psgi

Lines changed: 0 additions & 1 deletion
This file was deleted.

config/docker-compose.development.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
HOST_PORT=5010
2+
PLACKUP_ARGS='-R lib,bin'
3+
CPAN_VOLUME_PATH=../metacpan-cpan-extracted-lite

config/docker-compose.production.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
HOST_PORT=5055
2+
PLACKUP_ARGS='-E production -s Starman --workers=10 -l /tmp/app.sock'
3+
CPAN_VOLUME_PATH=/metacpan-cpan-extracted

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
3+
grep:
4+
build:
5+
context: .
6+
args:
7+
APP_ENV: development
8+
env_file:
9+
- .env
10+
environment:
11+
- MY_SHARED_ENV=value
12+
volumes:
13+
- ./config:/app/config
14+
- ${CPAN_VOLUME_PATH}:/metacpan-cpan-extracted
15+
ports:
16+
- "${HOST_PORT:-8088}:3000"
17+
container_name: grep-container
18+
19+
volumes:
20+
myapp-data:

0 commit comments

Comments
 (0)