Skip to content

Commit 83c805c

Browse files
authored
Merge pull request #137 from cmu-delphi/sgratzl/docker
docker image
2 parents 4f8ccc3 + 8d4e914 commit 83c805c

File tree

9 files changed

+67
-12
lines changed

9 files changed

+67
-12
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.git

.github/workflows/ci_fast.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,33 @@ jobs:
3535
with:
3636
name: website
3737
path: ./public
38+
39+
- name: Configure AWS credentials
40+
uses: aws-actions/configure-aws-credentials@v1
41+
with:
42+
aws-access-key-id: ${{ secrets.DELPHI_ECR_ACCESS_ID }}
43+
aws-secret-access-key: ${{ secrets.DELPHI_ECR_ACCESS_KEY }}
44+
aws-region: us-east-1
45+
46+
- name: Login to Amazon ECR
47+
id: login-ecr
48+
uses: aws-actions/amazon-ecr-login@v1
49+
50+
- name: Build, tag, and push image to Amazon ECR
51+
env:
52+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
53+
ECR_REPOSITORY: ${{ github.event.repository.name }}
54+
run: |
55+
baseRef="${GITHUB_REF#*/}"
56+
baseRef="${baseRef#*/}"
57+
case "${baseRef}" in
58+
main)
59+
awsTag="latest"
60+
;;
61+
*)
62+
awsTag="${baseRef//\//_}" # replace `/` with `_` in branch name
63+
;;
64+
esac
65+
echo "using tag: --${awsTag}--"
66+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$awsTag --file ./devops/precompiled/Dockerfile .
67+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$awsTag

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
*.woff2
2525
*.R
2626
*.xml
27+
.dockerignore
2728
*.Rmd
2829
*.md
2930
*.jpeg
30-
*.ico
31+
*.ico

Dockerfile

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

devops/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# docker image building and packaging the website
2+
FROM node:lts-buster AS builder
3+
WORKDIR /src
4+
COPY . ./
5+
RUN npm ci --unsafe-perm
6+
RUN npm run build
7+
8+
FROM nginx:stable-alpine
9+
COPY --from=builder /src/public /usr/share/nginx/html
10+
# ensure files are readable at runtime
11+
RUN chmod o+r -R /usr/share/nginx/html/

devops/precompiled/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# docker image using the current built website
2+
FROM nginx:stable-alpine
3+
4+
COPY ./public /usr/share/nginx/html
5+
# ensure files are readable at runtime
6+
RUN chmod o+r -R /usr/share/nginx/html/

devops/r/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# docker image for setting up an R environment
2+
FROM continuumio/miniconda
3+
4+
ADD ./environment.yml .
5+
RUN conda env create -f environment.yml
6+
7+
ADD ./dependencies.R .
8+
9+
RUN conda run -n www-main Rscript ./dependencies.R
10+
11+
ENV PATH /opt/conda/envs/www-main/bin:$PATH

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ version: "3.1"
33
# docker services for R environment and Hugo runner
44
services:
55
r:
6-
build: "."
6+
build:
7+
context: .
8+
dockerfile: devops/r/Dockerfile
79
working_dir: "/app"
810
command: tail -F anything
911
volumes:
1012
- "./:/app"
1113
# run: docker-compose exec r bash
12-
# conda activate www-main
1314
# Rscript -e 'blogdown::build_site(run_hugo=FALSE, build_rmd=TRUE)'
1415

1516
# see https://github.com/peaceiris/hugo-extended-docker

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"start": "hugo server -D",
2727
"start:blog": "Rscript -e \"blogdown::serve_site()\"",
2828
"format": "prettier *.* \"(.vscode|content|data|themes)/**\" --write",
29-
"lint": "prettier *.* \"(.vscode|content|data|themes)/**\" --check"
29+
"lint": "prettier *.* \"(.vscode|content|data|themes)/**\" --check",
30+
"image": "docker build -t www-main:latest --file ./devops/Dockerfile ."
3031
},
3132
"hugo-bin": {
3233
"buildTags": "extended"

0 commit comments

Comments
 (0)