Skip to content

Commit 41d86fa

Browse files
authored
Implement Docker support (#583)
1 parent 63c4a4b commit 41d86fa

File tree

6 files changed

+958
-2
lines changed

6 files changed

+958
-2
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
2+
react/node_modules
23
.git
3-
.gitignore
4+
.gitignore

.github/workflows/docker.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [react-rewrite]
6+
tags: ["v*"]
7+
8+
jobs:
9+
Build-and-Push:
10+
runs-on: ubuntu-24.04
11+
12+
# We want to filter out dependabot
13+
# automated pushes to main
14+
if: ${{ github.actor != 'dependabot[bot]'}}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Prepare Docker Meta
20+
id: meta
21+
uses: docker/metadata-action@v5
22+
with:
23+
images: |
24+
ghcr.io/ucmercedacm/chapter-website
25+
tags: |
26+
type=semver,pattern={{version}}
27+
type=semver,pattern={{major}}.{{minor}}
28+
type=semver,pattern={{major}}
29+
type=edge,branch=main
30+
31+
- name: Setup Docker Buildx
32+
id: buildx
33+
uses: docker/setup-buildx-action@v3
34+
with:
35+
version: latest
36+
37+
- name: Login to GitHub Container Registry
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.repository_owner }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Build and push image
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
file: ./docker/Dockerfile
49+
push: true
50+
cache-from: type=registry,ref=ghcr.io/ucmercedacm/chapter-website-build-cache:server
51+
cache-to: type=registry,mode=max,ref=ghcr.io/ucmercedacm/chapter-website-build-cache:server
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}

docker/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM node:22-bookworm-slim
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update \
6+
&& apt-get install -y --no-install-recommends \
7+
tini \
8+
&& apt-get clean
9+
10+
WORKDIR /website
11+
COPY /react /website
12+
13+
RUN adduser --disabled-password --gecos "" website \
14+
&& chown -R website:website /website/
15+
16+
USER website
17+
18+
RUN npm ci --ignore-scripts \
19+
&& npm run build
20+
21+
EXPOSE 3000
22+
23+
ENTRYPOINT ["/usr/bin/tini", "--"]
24+
25+
CMD ["npm", "run", "serve"]
26+
27+
STOPSIGNAL SIGTERM
28+
29+
HEALTHCHECK --interval=5m --timeout=3s CMD ["curl", "-f" , "http://localhost:3000/", "||", "exit 1"]
30+
31+
LABEL org.opencontainers.image.title="Chapter-Website"
32+
LABEL org.opencontainers.image.description="ACM @ UC Merced's website"
33+
LABEL org.opencontainers.image.licenses="Apache-2.0"
34+
LABEL org.opencontainers.image.source="https://github.com/UCMercedACM/Chapter-Website"

docker/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: chapter-website
2+
3+
services:
4+
chapter-website:
5+
container_name: chapter-website
6+
image: ghcr.io/ucmercedacm/chapter-website:edge
7+
ports:
8+
- 3000:3000
9+
healthcheck:
10+
test: curl -f http://localhost:3000/ || exit 1
11+
interval: 5m
12+
start_interval: 30s
13+
start_period: 5m
14+
restart: always

0 commit comments

Comments
 (0)