Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,18 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Build frontend
uses: addnab/docker-run-action@v3
with:
image: node:lts-gallium
options: -v ${{ github.workspace }}/web:/work -e REACT_APP_VERSION=${{ env.RELEASE_VERSION }} -e REACT_APP_GITHUB_URL='https://github.com/x1unix/go-playground' -e NODE_ENV=production
run: |
yarn --cwd='/work' install --silent && yarn --cwd='/work' build
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
file: ./build/Dockerfile
file: ./build/release.dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run:

.PHONY:ui
ui:
@cd $(UI) && REACT_APP_LANG_SERVER='//$(LISTEN_ADDR)' REACT_APP_VERSION=testing yarn start
@REACT_APP_LANG_SERVER='//$(LISTEN_ADDR)' REACT_APP_VERSION=testing yarn --cwd="$(UI)" start

.PHONY: cover
cover:
Expand Down
4 changes: 2 additions & 2 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ collect-meta:
.PHONY:preinstall
preinstall:
@echo ":: Checking and installing dependencies..." && \
cd $(UI) && $(YARN) install --silent
$(YARN) --cwd="$(UI)" install --silent

.PHONY:build-server
build-server:
Expand All @@ -42,7 +42,7 @@ build-server:
.PHONY:build-ui
build-ui:
@echo ":: Building UI..." && \
cd $(UI) && $(YARN) build
$(YARN) --cwd="$(UI)" build

.PHONY:build-webworker
build-webworker:
Expand Down
44 changes: 44 additions & 0 deletions build/release.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This dockerfile is intended to run only by GitHub Actions
# for multi-arch builds.
#
# This Dockerfile builds only Go code, because building
# frontend twice for different platform takes too long
# inside VM and makes no sence.
#
# Use Dockerfile for simple single-arch build process

FROM golang:1.18-alpine as build
WORKDIR /tmp/playground
COPY cmd ./cmd
COPY pkg ./pkg
COPY go.mod .
COPY go.sum .
ARG APP_VERSION=1.0.0
RUN echo "Building server with version $APP_VERSION" && \
go build -o server -ldflags="-X 'main.Version=$APP_VERSION'" ./cmd/playground && \
GOOS=js GOARCH=wasm go build -o ./worker.wasm ./cmd/webworker && \
cp $(go env GOROOT)/misc/wasm/wasm_exec.js .

FROM golang:1.18-alpine as production
WORKDIR /opt/playground
ENV GOROOT /usr/local/go
ENV APP_CLEAN_INTERVAL=10m
ENV APP_DEBUG=false
ENV APP_PLAYGROUND_URL='https://play.golang.org'
ENV APP_GOTIP_URL='https://gotipplay.golang.org'
ENV APP_GTAG_ID=''
COPY data ./data
COPY /tmp/web/build ./public
COPY --from=build /tmp/playground/server .
COPY --from=build /tmp/playground/worker.wasm ./public
COPY --from=build /tmp/playground/wasm_exec.js ./public
EXPOSE 8000
ENTRYPOINT /opt/playground/server \
-f='/opt/playground/data/packages.json' \
-clean-interval="${APP_CLEAN_INTERVAL}" \
-debug="${APP_DEBUG}" \
-playground-url="${APP_PLAYGROUND_URL}" \
-gotip-url="${APP_GOTIP_URL}" \
-gtag-id="${APP_GTAG_ID}" \
-permit-env-vars="${APP_PERMIT_ENV_VARS}" \
-addr=:8000