Skip to content

Commit

Permalink
feat(build): add Docker configuration (#258)
Browse files Browse the repository at this point in the history
Ref  #182
  • Loading branch information
Li-Gru committed Jul 27, 2023
1 parent 55be48c commit f43c0e0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM docker.io/library/golang:1.20.6-alpine3.18
WORKDIR /src
RUN apk add --no-cache build-base sassc
COPY go.sum go.mod ./
RUN go mod download && go mod tidy
COPY . /src
RUN set -x \
&& mkdir -p web/static/css \
&& for f in web/scss/*.scss; do sassc --style nested --sourcemap=inline -l "$f" "web/static/css/$(basename $f .scss).css";done \
&& go build -v -o bin/userstyles-fonts cmd/userstyles-fonts/main.go \
&& go build -v -o bin/userstyles-ts cmd/userstyles-ts/main.go \
&& go build -v -o bin/userstyles -tags "fts5" cmd/userstyles-world/main.go

FROM docker.io/library/alpine:3.18
RUN apk add --no-cache vips-tools
WORKDIR /data
ENV DATA_DIR=/data
ENV DB=userstyles.db
COPY --from=0 /src/bin/ /usr/local/bin/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["userstyles"]
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.9"
services:
app:
build:
dockerfile: Dockerfile
context: .
ports: ["3000:3000"]
5 changes: 5 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -Eeo pipefail
set -x
[ -f "${DATA_DIR}/${DB}" ] || DB_DROP=1 DB_MIGRATE=1 userstyles
exec "$@"

0 comments on commit f43c0e0

Please sign in to comment.